score:18
if this issue happens while you're linking the local version of your library in your main project to speed up the development. it might be related to "duplicate version of react".
https://reactjs.org/warnings/invalid-hook-call-warning.html
this problem can also come up when you use npm link or an equivalent. in that case, your bundler might “see” two reacts — one in application folder and one in your library folder. assuming myapp and mylib are sibling folders, one possible fix is to run npm link ../myapp/node_modules/react from mylib. this should make the library use the application’s react copy.
in short:
- run
npm link
in /your-app/node_modules/react. this should make the react's global link. - run
npm link react
in /your-ui-library. this should make the library use the application’s react copy.
score:1
i have the same issue, working with a rush monorepo, configuring ui-package and building the apps using nextjs.
the solutions was add the follow code on package.json
"resolutions": {
"react": "17.0.1", // verificate your react version
"react-dom": "17.0.1"
}
see more here: https://github.com/vercel/next.js/issues/9022#issuecomment-728688452
Source: stackoverflow.com
Related Query
- React + Antd + Rollup Component Library "Error: Invalid hook call. Hooks can only be called inside of the body of a function component"
- React Redux-Toolkit: Invalid hook call - Hooks can only be called inside of the body of a function component
- React call from class to functional component. Error: Invalid hook call. Hooks can only be called inside of the body of a function component
- React hooks in react library giving Invalid hook call error
- React 17.0.1: Invalid hook call. Hooks can only be called inside of the body of a function component
- Invalid hook call. Hooks can only be called inside of the body of a function component when i call useQuery in useEffect
- React Hooks Mobx: invalid hook call. Hooks can only be called inside of the body of a function component
- Invalid hook call. Hooks can only be called inside... how to fix this maintaining the react class component
- error: invalid hook call Hooks can only be called inside of the body of a function component
- React Hooks: Instantiating state hooks on validation Error: Invalid hook call. Hooks can only be called inside of the body of a function component
- React Hooks + Mobx => Invalid hook call. Hooks can only be called inside of the body of a function component
- React - Invalid hook call. Hooks can only be called inside of the body of a function component
- Invalid hook call. Hooks can only be called inside of the body of a function component in react 18
- React Router: Invalid hook call. Hooks can only be called inside of the body of a function component
- React and Easybase - Invalid hook call. Hooks can only be called inside of the body of a function component
- React hook Error: Invalid hook call. Hooks can only be called inside of the body of a function component
- Getting Invalid hook call Hooks can only be called inside of the body of a function component with SharePoint Framework Template
- Invalid hook call. Hooks can only be called inside of the body of a function component error
- Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component when using Create React App and Formik
- I am getting the error Invalid hook call. Hooks can only be called inside of the body of a function component
- React 17 - Adding Evergreen UI Pane Gives an Error: Invalid hook call. Hooks can only be called inside of the body of a function component
- Server Error Error: Invalid hook call. Hooks can only be called inside of the body of a function component in _app.js
- React - Error: Invalid hook call. Hooks can only be called inside of the body of a function component
- React useEffect Invalid hook call. Hooks can only be called inside of the body of a function component
- Invalid hook call. Hooks can only be called inside of the body of a function component
- Invalid hook call. Hooks can only be called inside of the body of a function component when apply style to class base component with material-ui
- react-router-dom: Invalid hook call, Hooks can only be called inside of the body of a function component
- Cant use Hooks with my React Component Library. Invariant Violation: Invalid hook call
- BrowserRouter causing Invalid hook call. Hooks can only be called inside of the body of a function component
- React: Invalid hook call. Hooks can only be called inside of the body of a function component
More Query from same tag
- How to add element in array
- How to arrange next button after play button
- Flask - Deserialize JSON and load to Postgres DB
- Send props in .map() function
- Updating the product image based on thumbnail img using react hooks
- SASS SCSS issue with input styles with react
- how to change style of a part of string when click :Reactjs
- React Router path is not working
- ReactJs: render a collection of dynamic components
- Listen for keypress / keydown event locally in react router component
- How to customise DialogTitle in material-ui
- How do we stop the re-rendering of A and B in React?
- React DataTable fails to change the font-size
- Error: Exception in HostFunction: java.lang.IllegalStateException: Failed to initialise the native Bugsnag Android client
- Why do we need default export in React?
- How to fetch an object array from Flux dispatcher in React?
- p5js resizeCanvas is not a function on resize
- Call again a function when state changes
- Use value of an Input in a function
- how to hide components on click of router link
- Multiple path names for a same component in React Router
- Is it possible to modify a cell of the react-day-picker with an image?
- How to iterate through a list of objects from api and render it to jsx page React functional component
- React Calendar with Touch Events
- ReactJS: run function to spawn elements from different pages without interaction
- How can i get :params from location?
- The values iterated by .map() do not reflect inside the function in html attribute
- React Context Provide not passing the value to the Consumer
- Post request from react to flask
- cannot import electron in react componment for ipcRenderer