Refactoring to Set Initial State from the Reducer
Explore how to refactor Redux state handling by moving initial state setting from the createStore method to the reducer using ES6 defaults. This lesson helps you understand efficient state initialization practices for smoother application management in a React environment.
We'll cover the following...
We'll cover the following...
Firstly, please have a look at the creation of the store in store/index.js. In particular, consider this line of code:
const store = createStore(reducer, { contacts });
The initial state object is passed directly into createStore. Remember that the store is created with the signature, createStore(reducer, ...