patternfly-react icon indicating copy to clipboard operation
patternfly-react copied to clipboard

after update, Invalid hook call error

Open kzolti opened this issue 5 years ago • 2 comments

old project use: dependencies": { "@patternfly/react-core": "^3.153.3", "@patternfly/react-icons": "^3.15.16", "@patternfly/react-styles": "^3.7.12", "@patternfly/react-table": "^2.28.29", "react": "^16.13.1", "react-router-dom": "^5.1.2" } throws an error on many items after an upgrade: Error: 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:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

I also reproduced the error in a new project: npm init npm install @patternfly/react-core --save create-react-app test

package.json: { "name": "test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "@patternfly/react-core": "^4.106.2" } }

index.js: import React from 'react'; import ReactDOM from 'react-dom'; import {Button} from '@patternfly/react-core'; ReactDOM.render( <React.StrictMode> </React.StrictMode>, document.getElementById('root') ); Screenshot_20210405_220950 Screenshot_20210405_221035 Screenshot_20210405_222034

kzolti avatar Apr 05 '21 20:04 kzolti

I tested it on another machine, and I could not reproduce the problem. After a short investigation, I realised that there is system and a user npm and nodejs installed. Removing the local version solved the problem. The ticket can be closed.

kzolti avatar Apr 06 '21 20:04 kzolti

Thank you for verifying that. I will close the issue.

tlabaj avatar Apr 08 '21 17:04 tlabaj