Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-route state issue #4197

Closed
emreakdas opened this issue Feb 14, 2024 · 1 comment
Closed

Per-route state issue #4197

emreakdas opened this issue Feb 14, 2024 · 1 comment

Comments

@emreakdas
Copy link

https://redux-toolkit.js.org/usage/nextjs#per-route-state In my nextjs project I need to reset a value in SPA navigation, this is the suggested solution, but this solution

Warning: Cannot update a component (Page) while rendering a different component (Detail). To locate the bad setState() call inside Detail, follow the stack trace as described in https://reactjs.org/link/setstate-in-render ```

when I did a little research, this usage was allowed before, but now it is not. facebook/react#18178 (comment) @markerikson has a comment here. if this usage is not allowed, why is this usage recommended in the document?

@markerikson
Copy link
Collaborator

This isn't an ideal pattern, and that example probably should move the dispatch into a layout effect or something. That said, if it's happening in the root of a component tree, I'd also expect that there aren't any components that are subscribed at that point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants