DEV Community

Sakthi S
Sakthi S

Posted on

What is Hook ?

  • React Hooks
    are functions that allow you to use state and other React features, such as lifecycle methods and context, within functional components.

  • Hooks let you use different React features from your components. You can either use the built-in Hooks or combine them to build your own. This page lists all built-in Hooks in React.

*Commonly Used Built-in Hooks *

  • useState: Adds state variables to a functional component and provides a function to update that state.

  • useEffect: Manages side effects, such as data fetching, subscriptions, or manual DOM updates

  • useContext: Allows components to subscribe to React's Context API, making it easier to share data across the component tree without "prop drilling".

  • useReducer: A more advanced state management Hook for handling complex state logic, often as an alternative to useState.

  • useRef: Returns a mutable ref object that can persist values across renders or directly access DOM elements.

  • useMemo / useCallback: Performance optimization Hooks that memoize expensive calculations or function definitions, preventing unnecessary re-renders of components.

Top comments (0)