-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve rehydration logic, merge state instead of replacing it.
- Loading branch information
Showing
1 changed file
with
10 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3d9b0ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this feels like a substantial change in behaviour. Would you mind elaborating on the reason for the change?
3d9b0ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @psychedelicious, there was already a state merge happening at the rememberReducer() level. So we basically did the same thing previously on a different level, but the state might become out of date by the time we rehydrated inside the enhancer (e.g. in case Next.js SSR rehydration fired before ours).
This change makes sure we always have updated state before rehydrating over it.
I've tested this extensively and made sure none of the existing functionality is broken.
Would this by any chance break anything on your side?
3d9b0ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying. I think I need to read through the code again to fully grok the implications, but I agree with the change insofar as it makes the behavior consistent.
I don't think it would break anything. I'll test before we update and create an issue if needed.
Thanks again for your continued work on this library!
3d9b0ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to follow up on this - I haven't noticed any issues or changes in behavior 👍