allenai / pdf-component-library

51 stars 5 forks source link

Mjlangan/reorganize #16

Closed mjlangan closed 3 years ago

mjlangan commented 3 years ago

This reorganizes the repository so there's separate webpack configs to build/test/run the library and the hello world app. The intent here is for the library to be built/tested/published from the root of the repository and the hello world app is its own self-contained project under /example.

npm link can be used to use the library as a dependency of the hello world app in the future (right now its just importing the files directly).

There is an issue that's baffling me and might be due to the change in folder structure and webpack finding multiple Reacts. The Overlay throws this error once the PDF loads and we try to render it:

Uncaught (in promise) Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem. at resolveDispatcher (react.development.js?aef8:1476) at Object.useContext (react.development.js?aef8:1484) at Overlay (Overlay.tsx?3620:12)

There is some documentation on this issue in the official React docs here: https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react I only see one react when I npm ls react within /example but I haven't yet tried the logging trick they suggest.