Blocking issue on useDropdown
hook not working when importing this package
#1
Labels
useDropdown
hook not working when importing this package
#1
Hello everyone, I now encounter a serious problem when using the package in other project, and with this problem present I can't continue the development since I cannot test my package in a real project. It would be greatly appreciated if any help could be given on the problem.
Recently I've implemented a custom hook called
useDropdown
which returns stateopen
and functiontoggle
to toggle the state of the dropdown. The source code can be found here.The implementation is quite simple: using
useState
to track down the state,useCallback
to provide a consistent toggle function, and another hookuseEventListener
to register event to close the dropdown when user click somewhere other than the dropdown itself.This function works fine when the code are copied into another project (in my case, a new Gatsby project initialized with
gatsby-cli
). However, when the function is imported into the same project (by usingyarn link
in this project, andyarn link "vicui"
in the gatsby-based project), the call touseDropdown
would crash the application with the following error messages:Some common causes that may lead to this error are checked and none of them actually exist. They include:
npm ls react/react-dom
reports only one react and one react-domTo reproduce the bug, try the following steps:
yarn install
andyarn build
to build a versionyarn link
gatsby-cli
with this quick start guideyarn link "vicui"
in the newly-initialized projectuseDropdown
hook in any existing component like below:header.js
yarn develop
and you will see the errors.I have completely no idea why this error would occur and have been strugging on it for several days. It may have something to do with modules resolution machanism, but I don't think I could solve it on my own.
I'll appreciate it very much If anyone could give the problem a look. Thanks for you all!
The text was updated successfully, but these errors were encountered: