- Whenever you use Hooks, you must always use it inside a component.
-
View React version:
npm view react version
-
The hook useReducer is an alternative to useState when managing complex states in your app.
- Context provides a way to pass data through the component tree without having to pass props down manually at every level
- Composition is a powerful React pattern used to create generic and reusable components by using props to pass data down to other components.
- Props are arguments passed from one component to another. They are like HTML attributes and are used to create reusable and flexible React components.
- Inline styling of HTML elements is done like this:
<form className="mb-2" style={{ textAlign: "left" }}> ... </form>
-
The
useReducer
Hook is similar touseState
—you must pass it an initial state and it returns a stateful value and a way to set state (in this case, the dispatch function). But it’s a little different.The
useReducer
Hook takes two arguments:- A reducer function
- An initial state
And it returns:
- A stateful value
- A dispatch function (to “dispatch” user actions to the reducer)