-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Changed behavior between 1.6.0 and 1.5.0 #1327
Comments
What did indeed change, was that we are freezing the initial state passed into So where previously, an action targeted at an empty reducer case might have triggered that "first freezing" and as such an involuntary rerender, that state is now frozen from the beginning, avoiding that rerender. I would consider that a bugfix, as the behaviour from before was definitely not correct. |
I can see that the old behavior is wrong. However, the new behavior is producing more rerenders for me because previously starting with the second action, the state did not change anymore. While with the new behavior, the state is always changing. I noticed one endless loop in my code base after updating to v1.6.0 because of this change. Although, the code triggering this effect was definitely wrong. |
Apart from that "initial freeze" nothing on our side changed and nothing could explain that changed behaviour you are experiencing there. Could this have something to do with the change to |
Freezing doesn't, as far as I know, return a new reference. It just marks the existing reference as being a frozen object. The example is confusing, because the reducer references Can you put up a CodeSandbox that actually demonstrates what you're talking about? |
I think the problem seems to be that assigning a value (here |
Sure, the CodeSandbox is exactly the same and can be found here: -> https://codesandbox.io/s/cold-cookies-ztywn I have updated the action to explicitly use undefined instead of leaving out the parameter which will result in the same problem. The sandbox will return false, true, true in the old version; changing to v1.6.0 will print false, false, false. |
I really can't think of any changes we would have made that would relate to this. Can you try putting together a similar demo that only uses Immer, and compare behavior with Immer v8 vs v9? |
Yesterday, I was not able to reproduce the issue with only immer. However; I got the same example now showing the same effect with immer only. |
I took your test and rewrote the "test" part of it to be more legible. Nothing unexpected happens there. I assume it is an error of the test - take a look here: |
@phryneas Changing @reduxjs/toolkit to v1.6.0 shows the errors again; that's interesting. |
I see that now, but it doesn't seem to appear in 1.6.1. |
Thanks for investigating the issue. I also rechecked with only immer and the issue seems to be fixed with 9.0.5; version before that show the issue. Seems to be related to immerjs/immer#807 |
Okay, then it's probably that. |
The following code prints false, true true in v1.5.0 and false, false false in v1.6.0. Seems to be related to some createSelector changes.
The text was updated successfully, but these errors were encountered: