question-mark
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.

Loading from the storage does not overwrite initial state completely

See original GitHub issue

Hi, it seems that loading from the storage does not overwrite the initial state completely, and that looks like a bug for me. ( If it’s not, please tell me how I can work with it productively. 😃 )

An example: Let’s say, this is my initial state:

state = {
  ...
  test: {
    foo: 1,
  }
  ...
}

Then, in some dispatch, I change the value of test:

nextState.test = { bar: 2 };

With redux-storage set up, this is saved (I guess).

When I now close/reopen or reload the whole app, I have this state:

state = {
  ...
  test: {
    bar: 2,
    foo: 1,
  }
  ...
}

I think, there should be no foo: 1 at this point, should it?

At least it’s bugging me in my app, so what’s the correct way of getting rid of it? Is there a config option for redux-storage that I can set?

(See the whole code here.)

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
chandlervdwcommented, Jul 31, 2017

+1, this is very confusing. The previous version this was forked from definitely loaded the stored state upon calling load(store). This seems to fire the REDUX_STORAGE_LOAD action but doesn’t actually update the redux state… is it required to import LOAD from redux-storage in my own reducer?

0reactions
anwarhamrcommented, Dec 11, 2017

I was having the same issue, but found it to be a copy/paste mistake. I missed/overlooked/forgot to add the reducer created by storage.reducer(rootReducer) to my call to createStore call. Loading the reducer is the key to all of this happening.

One other issue I’ve found that you want to be careful of, if you persist complex objects for instance Moment, you will need to handle the LOAD event in your reducer and convert it to an object. You can also probably do this using the optional parameters replacer, reviver to createEngine if it supports them; redux-storage-engine-localstorage does.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading from Redux storage does not overwrite initial state ...
it seems that loading from the Redux storage does not overwrite the initial state completely, and that looks like a bug for me....
Read more >
Always loading initialState · Issue #189 · rt2zz/redux-persist
Great package! When I tried this, it seems that it always loads the initial state for me. My code looks like this: import...
Read more >
How S3 Versioning works - Amazon Simple Storage Service
When you PUT an object in a versioning-enabled bucket, the noncurrent version is not overwritten. As shown in the following figure, when a...
Read more >
Loading ORC data from Cloud Storage | BigQuery
For Write preference, choose Append to table or Overwrite table. If you want to ignore values in a row that are not present...
Read more >
Configure immutability policies for blob versions - Azure Storage
Immutability policies are not supported in accounts that have the ... After the storage account is created, you can configure a default ......
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found