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

Fix multiple store instances sharing the same state #614

Conversation

pradeepnschrodinger
Copy link
Collaborator

Description

The initial state object which is passed to createSlice was reused across multiple store instances.
This can lead to issues, similar to what we encountered in #369. I think this was re-introduced sometime during the redux-toolkit migration.

Fixed it by having the initialize reducer take care of instantiating a new copy to be used as the initial state.

Motivation and Context

#369

How Has This Been Tested?

Tested in LD and using our examples.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

The propsChange reducer was mutating state AND returning a new state object.
This is unsupported in immer, and the fix is to only either mutate or
only return the new state.

I went ahead with mutation as it's much easier on the developer.
The initial state object which is passed to createSlice was reused across multiple store instances.
Fixed it by having the `initialize` reducer take care of instantiating a new copy to be used as the initial state.
@pradeepnschrodinger pradeepnschrodinger added the v2.0-beta Tickets targeting the v2.0-beta branch. label Nov 17, 2021
@pradeepnschrodinger pradeepnschrodinger changed the base branch from v2.0-beta-fix-rowExpansion to v2.0-beta November 29, 2021 06:51
pradeepnschrodinger added a commit that referenced this pull request Dec 1, 2021
The initial state object which is passed to createSlice was reused across multiple store instances.
Fixed it by having the `initialize` reducer take care of instantiating a new copy to be used as the initial state.
@pradeepnschrodinger
Copy link
Collaborator Author

pradeepnschrodinger commented Dec 1, 2021

Merged locally through v2.0.0-beta.5

@pradeepnschrodinger pradeepnschrodinger deleted the v2.0-beta-fix-multiple-stores-sharing-state branch June 29, 2022 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.0-beta Tickets targeting the v2.0-beta branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants