Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Merge states instead of overriding it.

See original GitHub issue

Current behaviour

When I pass something like:

      keys: [
          app: ['locale']
      rehydrate: true

It will override all my initial app state keys, and only fills in the locale field.

This will break my app, and forces me to choose to either sync the wholeapp key, or nothing at all. Or alternatively, make an entirely new locale reducer on the root.

Expected behaviour

The state being merged similar to how it happens in a reducer:

   [currentKey]: {

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

BBlackwocommented, Apr 15, 2020

Closing this issue as it was fixed in version 6.0.0 which started doing a deep merge of the initial state and the local storage state.

pedepcommented, Mar 22, 2018

Not sure if there is an “easy” way to have access to the initial state of all reducers, but adding an initialState object to LocalStorageConfig, and then merging this object with state and rehydratedState in the initial action might be the easiest until a better solution is found. Not sure if this solution would be satisfactory, but it solved the issues i were having. I can put up a quick PR if you think its worth the time #84

I have closed my PR again, since i think this problem could be solved by #65

Read more comments on GitHub >

github_iconTop Results From Across the Web

React useState overwrites state object instead of merging
Instead of merging changes I make to a state object, React is overwriting it completely. Could this be caused by the context? I'm...
Read more >
Git is overwriting my code on merge. If someone else ... - Quora
No. It just updates the knowledge your local git has about the latest state of the remote. It does not overwrite local changes....
Read more >
How State Updates Are Merged in React | by Robin Kim
setState( ) is a method that is available to all React components. Invoking it lets React know that the component state has been...
Read more >
Customizing the behavior of cached fields - Apollo GraphQL
When the write occurs, the field's new value is set to the merge function's return value, instead of the original incoming value.
Read more >
Merge step overwriting shared vars? - SAS Communities
Solved: Hi, I have two datasets that both have ID and a number of other variables. Some of these variables exist on both...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found