question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React has detected a change in the order of Hooks called by Root

See original GitHub issue

Screenshot 2022-09-19 at 2 31 17 PM

I’m using Next.js, when I navigated to another page, this error occurred

this is the target page code

const count = signal(0);

function Counter() {
  return <button onClick={() => count.value++}>Value: {count.value}</button>;
}
export default Counter;
  • next: 12.2.5
  • react: 18.2.0
  • signals-react: 1.0.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jmeistrichcommented, Oct 8, 2022

For what it’s worth, I’ve come to the conclusion that this method of injecting useReducer into the current dispatcher can’t possibly work reliably and I’ve migrated legend-state away from it. We were seeing this bug in Next.js and users saw a similar bug in Expo Router, and in some Framer-Motion animations it was crashing as elements unmounted. After a lot of debugging I was not able to find a reliable solution. That combined with the React team telling us not to do it and that it would break soon made it seem untenable.

I hope you’re able to find a solution! But if not I hope I can save you some time knowing that it didn’t work for us.

0reactions
marvinhagemeistercommented, Oct 13, 2022

Fixed by #219

Read more comments on GitHub >

github_iconTop Results From Across the Web

"React has detected a change in the order of Hooks" but ...
I ran into this same error message in a component I was writing due to use of short-circuiting logic. This resulted in an...
Read more >
How to overcome warning 'React has detected a change in ...
A look at a functional component that under non-obvious circumstances triggers this React Hooks warning.
Read more >
React has detected a change in the order of Hooks called by ...
I see following error when I render a list. There are no if/else in the component which usually lead to such problem.
Read more >
react has detected a change in the order of hooks called - You ...
Hooks always need to be called in the same order (so adding new hooks conditionally is not allowed). Your code is breaking this...
Read more >
React has detected a change in the order of Hooks" but Hooks ...
The problem is that you're calling Event.Event() directly, even though it is a react component. That causes react to treat the hook calls...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found