React 16 introduced hooks, a new way of using stateful features in React components. React both has built-in hooks and provides a way to write custom hooks.
The following table summarizes the built-in React hooks:
Hook | Description |
---|---|
useState | Provides a way to store and update a stateful value. Updating the value triggers re-rendering. |
useEffect | Used to perform side effects. By default, the effect runs after each render. |
useLayoutEffect | Unlike useEffect , fires synchronously after DOM mutations while re-rendering. |
useContext | Returns the current value of a React context. |
useReducer | Similar to useState , but uses the same signature as Redux reducers. |
useMemo | Returns a memoized value. |
useCallback | Returns a memoized callback. |
useRef | Used to store component instance variables. |
useImperativeHandle | Used with forwardRef for exposing ref handlers to parent components. |
useDebugValue | Used for development/debugging. |