The different kinds of Hooks are listed below -
- The useState hook allows us to create state variables in a React function component.
- The useEffect lets us perform side effects in function components.
- Refs are a special attribute that are available on all React components. They allow us to create a reference to a given element / component when the component mounts. useRef allows us to easily use React refs. They are helpful (as in the example below) when we want to directly interact with an element, such as to clear its value or focus it, as with an input.
- The useCallback is a hook that is used for improving our component performance.
- The useMemo is very similar to useCallback and helps improve performance. But instead of being for callbacks, it is for storing the results of expensive operations.
- The useContext hook removes the unusual-looking render props pattern that was required in consuming React Context before.
- The useReducer is a hook for state management, much like useState, and relies upon a kind of function called a reducer.