August 2017
Beginner
374 pages
10h 41m
English
We still manually dispatch some actions in src/index.js to produce an initial state. When using persistState(), we need to make sure that we do not dispatch these actions again, as the state has already been initialised. Now we are going to ensure that we do not re-dispatch actions on refresh:
const initialState = store.getState()
if (!initialState.users || initialState.users.length === 0) { // create users store.dispatch(createUser('dan', 'Daniel Bugl')) store.dispatch(createUser('des', ...Read now
Unlock full access