create-react-library
create-react-library copied to clipboard
Error: Invalid hook call [styled-components]
I created a new app using create-react-app react-boilerplate template which uses styled-components.
Imported custom-ui-library
in the project which is also internally using styled-components.
"custom-ui-library": "file:../../custom-ui-library",
But getting the similar errors as discussed in #197 .
I tried peerDependencies fix provided by @beTTostd as well, but nothing seems to be working so far.
It works with the example project and plain create-react-app project when I add these dependancies in package.json
"custom-ui-library": "file:../../custom-ui-library",
"react": "file:../../custom-ui-library/node_modules/react",
"react-dom": "file:../../custom-ui-library/node_modules/react-dom",
"react-scripts": "file:../../custom-ui-library/node_modules/react-scripts"
Am I missing something? are there any other configurations needed in v3? Please suggest.
maybe you've since figured this out, but in case anyone finds this issue in the future, the reason this happens is because of the file://
imports (this also happens with npm link). it's an issue with react and not with CRL.
https://github.com/facebook/react/issues/13991
I faced similar issue before.
I think you can solve it with using npm pack
and install with the command npm i ../../custom-ui-library-x.y.z.tgz
instead of npm i ../../custom-ui-library
.
I wrote how to solve here