wojtekmaj / react-pdf

Display PDFs in your React app as easily as if they were images.
https://projects.wojtekmaj.pl/react-pdf
MIT License
9.11k stars 867 forks source link

Outline onItemClick function Getting Type Error - Type error: Binding element 'itemPageNumber' implicitly has an 'any' type. #1687

Closed donhook closed 6 months ago

donhook commented 7 months ago

Before you start - checklist

Description

I am getting the Error: Invalid pageIndex request when I click on an item in the outline. Not sure what the issue is....

Followed the Outline Recipe.

  function onItemClick({ pageNumber: itemPageNumber}) {
    setPageNumber(itemPageNumber);
  }

...

<Outline className="width:100" onItemClick={onItemClick} />

I have "noImplicitAny": true, in my ts.config

Steps to reproduce

Define the onItem Click Function in the page

function onItemClick({ pageNumber: itemPageNumber}) { setPageNumber(itemPageNumber); }

Define the outline tag

Expected behavior

Click on an outline item and the appropriate PDF page is displayed

Actual behavior

Receiving a type error in VS code: Type error: Binding element 'itemPageNumber' implicitly has an 'any' type.

Receiving an unhandled runtime error: Error: Invalid pageIndex request. When clicking on an outline item.

Additional information

Not sure what misconfiguration i have

Environment

  • Browser (if applicable):
  • React-PDF version:
  • React version:
  • Webpack version (if applicable): Chrome: v120.0 React: 18 React PDF: 7.6
wojtekmaj commented 6 months ago

Well add the type then!

  function onItemClick({ pageNumber: itemPageNumber }: { pageNumber: number }) {
    setPageNumber(itemPageNumber);
  }
donhook commented 6 months ago

Thanks for your time... i tried that, still didnt resolve issue. Will continue to see what I have wrong in the environment or setup.