Today We are Going To Solve Invalid hook call. Hooks can only be called inside of the body of a function component in reactjs. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.
Contents
How to Fix Invalid hook call. Hooks can only be called inside of the body of a function component Error?
- How to Fix Invalid hook call. Hooks can only be called inside of the body of a function component Error?
To Fix Invalid hook call. Hooks can only be called inside of the body of a function component Error just Run the command. Here you have to run the below command to solve your error
npm link <path_to_local_library>/node_modules/react
- Invalid hook call. Hooks can only be called inside of the body of a function component
To Fix Invalid hook call. Hooks can only be called inside of the body of a function component Error just Add this to your package.json. You have to just add this to your package.json
"peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" }
Solution 1 : Run the command
Here you have to run the below command to solve your error
npm link <path_to_local_library>/node_modules/react
Solution 2 : Add this to your package.json
You have to just add this to your package.json
"peerDependencies": {
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
}
Conclusion
So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.
Also Read These Solutions
- Attempted import error: ‘firebase/app’ does not contain a default export (imported as ‘firebase’)
- unexpected disconnect while reading sideband packet fatal: the remote end hung up unexpectedly
- Using / for division is deprecated and will be removed in Dart Sass 2.0.0 in Nuxtjs
- accessible: module java.base does not “opens java.io” to unnamed module
- error: invalid command ‘bdist_wheel’