Skip to content

Latest commit

 

History

History
51 lines (26 loc) · 2.47 KB

File metadata and controls

51 lines (26 loc) · 2.47 KB

Redux - Combined Reducers

Reading

  • Multiple Reducers Example

    • Why create multiple reducers?

      • Multiple slice reducers can respond to the same action, independently update their own slice as needed, and the updated slices are combined into the new state object. Because this pattern is so common, Redux provides the combineReducers utility to implement that behavior.
    • How would you combine multiple reducers?

      • You define multiple reducers to handle different pieces of your application's state, then compose these reducers together into one root reducer. The root reducer is then passed into the Redux createStore() method. In order to let us combine multiple reducers together, Redux provides the combineReducers() method.
    • How will you manage state as an immutable object? why?

      • Using immutable states allows us to write code that can quickly tell if the state has changed, without needing to do a recursive comparison on the data, which is usually much, much faster
  • 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.

      • 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?

      • combineReducers takes an object full of slice reducer functions, and creates a function that outputs a corresponding state object with the same keys
  • Redux Docs: Combined Reducer Syntax

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

      • they managing independent parts of state
    • The _____ helper function turns an object whose values are different reducing functions into a single reducing function you can pass to ____.

      • combineReducers createStore
    • What is a popular convention when naming reducers?

      • after the state slices they manage

Reflection

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

    • Just DSA so I can get confident with whiteboards