See the full :ref:`Use Reducer` docs for details Parameters: reducer: A function which applies an action to the current state in order to produce the next state. initial_value: The initial state value (same as for :func:`use_state`) Retur
(
reducer: Callable[[_Type, _ActionType], _Type],
initial_value: _Type,
)
| 297 | |
| 298 | |
| 299 | def use_reducer( |
| 300 | reducer: Callable[[_Type, _ActionType], _Type], |
| 301 | initial_value: _Type, |
| 302 | ) -> tuple[_Type, Callable[[_ActionType], None]]: |
| 303 | """See the full :ref:`Use Reducer` docs for details |
| 304 | |
| 305 | Parameters: |
| 306 | reducer: |
| 307 | A function which applies an action to the current state in order to |
| 308 | produce the next state. |
| 309 | initial_value: |
| 310 | The initial state value (same as for :func:`use_state`) |
| 311 | |
| 312 | Returns: |
| 313 | A tuple containing the current state and a function to change it with an action |
| 314 | """ |
| 315 | state, set_state = use_state(initial_value) |
| 316 | return state, _use_const(lambda: _create_dispatcher(reducer, set_state)) |
| 317 | |
| 318 | |
| 319 | def _create_dispatcher( |
nothing calls this directly
no test coverage detected