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:
You might have mismatching versions of React and the renderer (such as React DOM)
You might be breaking the Rules of Hooks
You might have more than one copy of React in the same app See react-invalid-hook-call for tips about how to debug and
Below are the steps I followed :
In Your Application:
a) cd node_modules/react && npm link
b) cd node_modules/react-dom && npm link
In Your Library
a) npm link react
b) npm link react-dom
3)Stop your dev-server and do npm start again.
Também adicionei o código abaixo no package.json. Não tenho certeza se isso afetou algo
"resolutions": {
"/react": "16.7.0-alpha.2",
"/react-dom": "16.7.0-alpha.2"
},
Code: https://github.com/transitive-bullshit/create-react-library
Tutorial: https://levelup.gitconnected.com/create-your-own-react-library-in-2020-step-by-step-7c39eb1b2d7b
Troubleshoot
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:
You might have mismatching versions of React and the renderer (such as React DOM) You might be breaking the Rules of Hooks You might have more than one copy of React in the same app See react-invalid-hook-call for tips about how to debug and
Below are the steps I followed :
In Your Application: a) cd node_modules/react && npm link b) cd node_modules/react-dom && npm link
In Your Library a) npm link react b) npm link react-dom
3)Stop your dev-server and do
npm start
again.Também adicionei o código abaixo no package.json. Não tenho certeza se isso afetou algo "resolutions": { "/react": "16.7.0-alpha.2", "/react-dom": "16.7.0-alpha.2" },