Reducers (1/14)
What is a reducer function?
    Understanding Reducer Functions in Redux Toolkit

    A reducer function in Redux Toolkit is a pure function that determines how the application's state changes in response to dispatched actions. It takes the current state and an action as arguments and returns a new state based on the action type and payload.

    Key Characteristics of a Reducer Function
    • Reducers are pure functions — they do not mutate the original state or cause side effects.
    • Each reducer listens for specific action types to decide how to update the state.
    • Reducers return the next state based solely on the current state and the dispatched action.
    Example: Basic Reducer Function in Redux Toolkit

    In this example, each function inside the `reducers` field is a reducer that modifies the state based on a specific action. Redux Toolkit uses the Immer library internally, allowing you to write reducers that 'mutate' state safely.