How to set initial state in Redux?

You need to pass initial state as second argument to createStore:

const rootReducer = combineReducers({
todos: todos,
visibilityFilter: visibilityFilter,
});
const initialState = {
todos: [{ id: 123, name: 'example', completed: false }],
};
const store = createStore(rootReducer, initialState);

Author of content
Edit this page

Made by Michael Sakhniuk

Twitter