Using Immutable.js state with redux-localstorage
See original GitHub issueI’m not sure how to setup the config parameter to properly use an Immutable object, This is how I configure the options:
import Immutable from 'immutable';
export const LocalStorageConfig = {
serialize: (subset) => subset.toJson(),
deserialize: (serializedData) => Immutable.fromJS(JSON.parse(serializedData)),
merge: (initialState, persistedState) => initialState.mergeDeep(persistedState)
};
But I get an error with my selector, state.get is not a function
:
export const menuSelector = createSelector(
mainSelector,
(state) => ({
menu: state.get('menu')
})
);
It looks like I’m missing something here.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
react/redux/immutable/redux persist - Stack Overflow
Have a redux application where the state is composed of Immutable Records. Looking to serialize / deserialize only a subset of my state...
Read more >Immutable.js vs Redux Persist | What are the differences?
It is a library allowing to save the redux store in the local storage of your browser. It promises to retain the users'...
Read more >redux-localstorage-simple - npm
Redux -LocalStorage-Simple. Save and load Redux state to and from LocalStorage. Supports Immutable.js data structures.
Read more >Using Immutable.js with Redux - Medium
The state consists of two leaves, byId and ids; used to store an array of objects (items) with primitive properties. The code is...
Read more >Mark Erikson on Twitter: "Good post on some reasons to avoid ...
Good post on some reasons to avoid using Immutable.js in Redux apps: ... codify ImmutableJs as a state atom and it has been...
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 FreeTop 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
Top GitHub Comments
I’ve improved
slicer
from the previous example.Use-case:
I got it to work with the following, which is changed from the initial comment. Also, I was tripped up when combining this with
combineReducers
and removed it.