0 votes
in ReactJS by

How to set initial state in Redux?

1 Answer

0 votes
by

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
)

Related questions

0 votes
0 votes
asked Mar 3, 2020 in ReactJS by miceperry
0 votes
asked Nov 1, 2021 in Artificial Intelligence by DavidAnderson
...