UseReducer:
useState and useReducer are the two native ways of managing state in React.
It is used for State management.
UseReducer is an advanced version of the useState hook.
Internally useReducer hook using the useState hook.
Syntax -
useReducer(reducer-function , initial-state);
Syntax -
Const [state, dispatcher] =
useReducer(reducer-function , initial-state);
Explanation related to properties -
State: State contains data
dispatcher: dispatcher is a function. This function tells what can actually do to the reducer function.
This function tells what kind of action can be done in the reducer function.
Syntax :