victory icon indicating copy to clipboard operation
victory copied to clipboard

Invalid hook call when I tried the tutorial

Open Hendricks27 opened this issue 1 year ago • 2 comments

To whom it may concern,

I was experimenting the tutorial on victory. While I was able to draw the bar chart, the following issue came when I tried to wrap VictoryBar with VictoryChart. Any suggestions are appreciated! Thanks!

Best, Wenjin

react.development.js:1476 Uncaught 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. at resolveDispatcher (react.development.js:1476:1) at Object.useState (react.development.js:1507:1) at Module.useAnimationState (use-animation-state.js:33:1) at VictoryChartImpl (victory-chart.js:28:1) at renderWithHooks (react-dom.development.js:16305:1) at mountIndeterminateComponent (react-dom.development.js:20074:1) at beginWork (react-dom.development.js:21587:1) at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1) at invokeGuardedCallback (react-dom.development.js:4277:1)

Hendricks27 avatar Sep 12 '22 08:09 Hendricks27

Someone else also had a similar issue here: https://stackoverflow.com/questions/72940866/react-victorychartimpl-invalid-hook

Hendricks27 avatar Sep 12 '22 08:09 Hendricks27

Hi @Hendricks27 – I'm trying to reproduce this, but am not getting this error. Would you share which version of Victory you're using?

gksander avatar Sep 13 '22 14:09 gksander

Hi. I'm having the same problem. Version used: "victory-native": "^35.3.3"

feardarkness avatar Dec 05 '22 22:12 feardarkness

I had quite similar issue after upgrading my expo app to 48. The app kept crashing with Error: Invalid hook call even though the library has been running without a single issue for ages. victory-native at that time was "victory-native": "^35.3.2".

Then I initiated a new clean expo project with the latest victory-native version "^36.6.8" and react-native-svg "^13.9.0" installed. It runs the official tutorial demo perfectly. More importantly, I noticed that the new app does not have react-dom

After that, I copied the versions of victory-native, react-native-svg, react-native and expo to my current project and remove react-dom from package.json. it works like a charm.

Hope this may help someone who is struggling with this.

twwspes avatar Apr 17 '23 19:04 twwspes

This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

github-actions[bot] avatar Feb 23 '24 21:02 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.

github-actions[bot] avatar Mar 01 '24 23:03 github-actions[bot]