I'm learning Immutable.js, but I'm having difficulty to handle with Immutable.js in reducers.
I've declared my initialState like this:
import { fromJS } from 'immutable';
const INITIAL_STATE = fromJS({
users: {
isLoading: false,
items: []
}
});
I'm trying to modify the initialState but I'm getting an error: "state.setIn is not a function".
case 'FETCH_USERS_SUCCESS':
return state
.setIn(['users', 'isLoading'], false)
.setIn(['users', 'items'], action.users)
In the index.js, I'm declaring the deafult state as a Immutable Map() object:
let store = createStore(..., Map({}), composeEnhancers(...));
And in the combineReducers I'm using the 'redux-immutable'.
import { combineReducers } from 'redux-immutable';
What is the right way to modify the reducer state with Immutable.js?