A Reducer describes how an application's state changes. You'll often see the Object Spread Operator (...) used inside of a reducer because a reducer must return a new object instead of mutating the old state.
The tweets reducer will determine how the tweets part of the state changes and the users reducer will determine how the users part of the state changes, and so forth.
Initializing State
There are 2 ways to initialize the state inside the store:
You can pass the initial state (or a part of the initial state) as preloadedState to the createStore function.
A Reducer describes how an application's state changes. You'll often see the Object Spread Operator (
...
) used inside of a reducer because a reducer must return a new object instead of mutating the old state.If you want to know why Redux requires immutability, check out the this document - https://redux.js.org/faq/immutable-data#why-is-immutability-required
Reducers have the following signature:
The
tweets
reducer will determine how thetweets
part of the state changes and theusers
reducer will determine how theusers
part of the state changes, and so forth.Initializing State
There are 2 ways to initialize the state inside the store:
preloadedState
to thecreateStore
function.https://redux.js.org/recipes/structuring-reducers/initializing-state