September 2018
Intermediate to advanced
302 pages
7h 17m
English
Instead of relying on the component state, let's lift it to a Redux store. Pay attention to the Immutable.Map we use here. Also, the ADD_TASK action is now using the update function from Immutable.js:
// src / Chapter 6 / Example 3 / src / reducers / taskReducer.jsconst taskReducer = (state = Immutable.Map({ entities: Immutable.List([]), isLoading: false, hasError: false, errorMsg: ''}), action) => { switch (action.type) { case TasksActionTypes.ADD_TASK: if (!action.task.name) { return state; } return state.update('entities', entities => entities.push({ name: action.task.name, description: action.task.description, likes: 0 })); default: return state; }};
As we have changed the reducer, we need to fix the stateful ...
Read now
Unlock full access