concept new state in category react

appears as: new state
React Hooks in Action

This is an excerpt from Manning's book React Hooks in Action.

  • A reducer uses actions to generate a new state from the previous state, making it easier to specify more complicated updates that may involve multiple pieces of inter-related state.
  • Figure 4.3 A reducer takes a state and an action and returns a new state.
    function reducer ( state, action ) {
      // use the action to generate a new state from the old state.
      // return newState.
    }