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
Initial state immutability #313
Comments
Please provide some example code to better illustrate what you expect versus the current behavior. Thanks! |
So taking the following example
And supose propA is a deeply nested property which is created prior to state initialization and as there are no changes to the state or properties propA will not be frozen. So i would expect that the produced state propA would have been frozen. |
Freezing is a very expensive process. Only *changes* that are introduced in
producers are frozen. Which is just a dev utility to detect errors earlier
(it is automatically disabled in production, so you can't really rely on it
as well). The goal of immer is not to deepFreeze things. For a guaranteed
full freeze, just use packages that exist for that, such as deepfreeze.
Op ma 11 feb. 2019 om 08:26 schreef Ivi Hamiti <notifications@github.com>:
… So taking the following example
const state = { propA: {}, propB: {}};
const mutated = produce(state, draft => {});
And supose propA is a deeply nested property which is created prior to
state initialization and as there are no changes to the state or properties
propA will not be frozen.
So i would expect that the produced state propA would have been frozen.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#313 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhDJw4cQg4pNCTCkTDHy4L6wQDY1Zks5vMRsUgaJpZM4ak8Pb>
.
|
I want to submit the same feature request too, then i found your discussion. Are there any simple and |
@chenhx2015 See here: #260 (comment) |
🎉 This issue has been resolved in version 4.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I am currently exploring immer for a use case of improving an component performance with immutability and angular OnPush change detection. I encountered a strange thing with the auto freezing (which by documentation is as expected) and wanted to know if this is a normal approach or i am pushing to make something work which is not the approach expected by immer.
So i have a complex component state (deeply nested). The sub properties of the object are not created as immutable using the produce but by simple object notation. When produce is called on the state, and the property values are set, immer will only freeze the setter/getter but not the value (which is an object).
I wanted to know if this is something that can be improved by immer or i am tackling this problem wrong and should create every object as immerable or using produce?
The text was updated successfully, but these errors were encountered: