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

<React.Strict> causes "You are attempting to modify the store during a render cycle" #98

Closed
davidgilbertson opened this issue Mar 19, 2020 · 0 comments

Comments

@davidgilbertson
Copy link
Owner

The issue seems to be <React.Strict>.
I think this sets debugRenderPhaseSideEffectsForStrictMode to true and calls instance.render() twice on purpose to test for issues.

https://github.com/facebook/react/blob/master/packages/shared/ReactFeatureFlags.js#L14.

So this double-registers a component starting to render, but only unqueues once when it's finished rendering.

But it also sometimes happens with Next.js running locally (when hot-reloading?). Maybe Next.js uses strict mode too, internally.

Pick one or more:
a) Make it stop. Add an instance._isRendering flag or something like that in collect.tsx
b) Link to the readme and add some workarounds for the error.
c) Log the component that's supposedly re-rendering.
d) Use <React.StrictMode> in tests.

Don't be clever and add a rule that says don't add a new currentComponent if it's the same name as the previous one. This would fail if the user had nested <Folder>s, for example.

@davidgilbertson davidgilbertson changed the title "You are attempting to modify the store during a render cycle" fires erroneously <React.Strict> causes "You are attempting to modify the store during a render cycle" Mar 19, 2020
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

1 participant