InterviewHubPRO
Section Overview
Q132

Question 132 of 445

Part 5: React Redux State Management (101 - 134)

30%
React & Modern Frontend (445 Qs)•Part 5: React Redux State Management (101 - 134)

How to set initial state in Redux?

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

javascript
const rootReducer = combineReducers({
todos: todos,
visibilityFilter: visibilityFilter,
});

const initialState = {
todos: [{ id: 123, name: "example", completed: false }],
};

const store = createStore(rootReducer, initialState);