wanting to act off of multiple pieces of information can turn into working with a massive reducer, making it difficult to maintain.
By useing the combineReducers function, it takes two objects as an argument, where the keys represent different aspects of the application state, and the values represent the corresponding reducer functions for those aspects.
you create a new object whenever the state needs to be updated. This approach has several benefits:
It makes the behavior of the application more predictable and easier to understand.
It ensures that data flows in one direction, making it simpler to track changes.
It allows for performance optimizations, making updates more efficient.
It enables features like time-travel debugging, which helps with issue reproduction and debugging.
Redux reducers
In order to assemble the new state tree, combineReducers will call each slice reducer with its current slice of state and the current action, giving the slice reducer a chance to respond and update its slice of state if needed.
There are two ways to define the initial shape and contents of your store’s state. First, the createStore function can take preloadedState as its second argument. This is primarily intended for initializing the store with state that was previously persisted elsewhere, such as the browser’s localStorage. The other way is for the root reducer to return the initial state value when the state argument is undefined
https://redux.js.org/usage/structuring-reducers/using-combinereducers/
As your app grows more complex, you’ll want to split your reducing function into separate functions, each managing independent parts of the state. The combineReducers helper function turns an object whose values are different reducing functions into a single reducing function you can pass to createStore. The resulting reducer calls every child reducer, and gathers their results into a single state object. The state produced by combineReducers() namespaces the states of each reducer under their keys as passed to combineReducers()
combineReducer, createStore
… to name reducers after the state slices they manage, so you can use ES6 property shorthand notation…
I only kind of understood how to implement recducer in the first place, so just want to be able to follow along and see how this gets initiated and utilized. Since the idea seems super helpful in keeping everything organized.