-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
Redux store.getState is not immutable #1739
Comments
@PartyHardy I think, that the main reason is performance. Copying object every time you want to get your state is obviously not a very good practice. And even if you copy it, it won't be deeply immutable. And deep copying is even less performant. So, if you're worrying about suddenly mutating your state, just deep freeze it in dev mode or use libraries like immutable.js or seamless-immutable, that will throw an error on attempt to mutate state. |
@smashercosmo is correct. |
There's also some dev tools that will warn you if you're mutating. See the DevTools#Linting section of my Redux addons catalog. |
I love redux and was a little surprised to see that getState or accessing any part of the state doesn't return a copy of the state. Is there a reason not to return Object.assign({}, "store.state")?
The text was updated successfully, but these errors were encountered: