Loading from the storage does not overwrite initial state completely
See original GitHub issueHi, 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:
- Created 6 years ago
- Comments:6
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+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 theREDUX_STORAGE_LOAD
action but doesn’t actually update the redux state… is it required to importLOAD
from redux-storage in my own reducer?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 tocreateStore
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.