Reading-Notes

Reading

Multiple Reducers Example

Why create multiple reducers?

wanting to act off of multiple pieces of information can turn into working with a massive reducer, making it difficult to maintain.

How would you combine multiple reducers?

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.

How will you manage state as an immutable object? why?

you create a new object whenever the state needs to be updated. This approach has several benefits:

Redux Docs: Using Combined Reducers

combineReducers is a utility function to simplify the most common use case when writing _ ___ .

Redux reducers

Explain how combineReducers assembles the new state tree.

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.

How would you define initial state in an app using combineReducers?

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/

Redux Docs: Combined Reducer Syntax

Why will you want to split your reducing functions as your app becomes more complex?

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()

The ___ helper function turns an object whose values are different reducing functions into a single reducing function you can pass to __.

combineReducer, createStore

… to name reducers after the state slices they manage, so you can use ES6 property shorthand notation…

Reflection

What are your learning goals after reading and reviewing the class README?

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.