useReducer
is an alternative to useState
that allows us to provide a function (called a "reducer") that manipulates state in a pre-defined way. useReducer
and the reducer
function allow us to manipulate state in more complex ways. The reducer
function is a helper function for state manipulation, and allows us to set new state based on the value of the previous state.reducer
function via the dispatch
method returned by useReducer
, which wraps our reducer
function and passes the relevant parameters to it. The 1st parameter passed to dispatch
is the 2nd parameter passed to reducer
, i.e. the action
JS Object parameter.useReducer
with useContext
's Provider
higher-order component to create a global-state-setting function that is available without lifting functions.