ReactJS Hooks Reference Last Updated : 17 Mar, 2025 Comments Improve Suggest changes Like Article Like Report React hooks are functions that allow you to use state and other React features in functional components. Hooks were introduced in React 16.8, enabling developers to manage state and lifecycle features without needing class components. They simplify the development process and make it easier to write reusable and cleaner code.Below is the basic representation of the React JS Hooks useState. CSS /* Write CSS Here */ .App { display: flex; flex-direction: column; justify-content: center; align-items: center; } body { background-color: antiquewhite; } .App>h2 { text-align: center; } .App>button { width: 8rem; font-size: larger; padding: 2vmax auto; height: 1.8rem; color: white; background-color: rgb(34, 34, 33); border-radius: 10px; } button:hover { background-color: rgb(80, 80, 78); } JavaScript import React, { useState } from 'react'; import './App.css' const App = () => { const [num, setNum] = useState(0); const handleClick = () => { setNum(num + 1); }; return ( <div className="App"> <h2> {num}</h2> <button onClick={handleClick}> Add one </button> </div> ); }; export default App; The useState hook is used to create a num state, initialized to 0, and a setNum function to update it when the button is clicked.The handleClick function increments num by 1 each time the button is clicked, updating the displayed value in the <h2> tag.OutputWhy Use React Hooks?Simplifies Code: Hooks provide a simpler and cleaner way to write components by using functions instead of classes.State and Side Effects: Hooks allow you to use state (useState) and side effects (useEffect) in functional components.Reusability: Hooks make it easier to share logic across components by creating custom hooks.Readability: Functional components with hooks tend to be more concise and easier to read than class components.Different Hooks in ReactuseState: useState is used to add state to functional components.useEffect: useEffect is used to perform side effects (like fetching data or subscribing to services) in functional components.useContext: useContext allows you to access the value of a context in functional components.useReducer: useReducer is an alternative to useState for more complex state logic.useRef: useRef returns a mutable ref object which can be used to reference DOM elements or store mutable values.useMemo: useMemo is used to memoize values or computations to prevent expensive calculations on every render.useCallback: useCallback is used to memoize functions so that they are not recreated on every render.useLayoutEffect: Similar to useEffect, but it runs synchronously after all DOM mutations, allowing you to perform operations on the layout.useImperativeHandle: useImperativeHandle customizes the instance value that is exposed when using ref in functional components.Advantages of Using HooksCleaner Code: Hooks make code simpler and easier to read by allowing state and effects to be used directly in functional components.Better Reusability: Custom hooks allow the reuse of logic across different components.No this keyword: Hooks eliminate the need for the this keyword found in class components, reducing complexity and mistakes.More Functionality in Functional Components: Previously, only class components could use lifecycle methods and state. Now, with hooks, even functional components can manage state, side effects, and other features.React JS Hooks ReferenceuseState HookuseEffect HookuseRef HookuseMemo HookuseContext HookuseReducer HookuseHistory HookuseNavigate HookuseParams HookuseLayoutEffect HookuseImperativeHandle HookuseDebugValue HookuseUndoState HookuseSelect HookuseCallback HookuseTransition HookuseId HookuseInsertionEffect HookReactJS Custom HooksuseLocalStorage Custom HookuseForm Custom HookuseTimeout Custom HookuseOrientation Custom HookuseInterval Custom Hook Comment More infoAdvertise with us Next Article ReactJS Hooks Reference kartik Follow Improve Article Tags : Web Technologies ReactJS React-Hooks Similar Reads ReactJS useReducer Hook The useReducer hook is an alternative to the useState hook that is preferred when you have complex state logic. It is useful when the state transitions depend on previous state values or when you need to handle actions that can update the state differently.Syntaxconst [state, dispatch] = useReducer( 5 min read ReactJS useEffect Hook The useEffect hook is one of the most commonly used hooks in ReactJS used to handle side effects in functional components. Before hooks, these kinds of tasks were only possible in class components through lifecycle methods like componentDidMount, componentDidUpdate, and componentWillUnmount.What is 4 min read Resource Hooks in React In React, components often need to access external resources such as data from promises or context information for styling. Managing these resources within the component state could lead to unnecessary complexity and performance overhead. React provides a simple solution with the 'use' hook to overc 3 min read Ref Hooks in React Ref Hooks provide a way to access and interact with the DOM (Document Object Model) nodes directly within functional components. Before hooks, refs were primarily used in class components. However, with Ref Hooks, functional components can also take advantage of this capability, enhancing flexibilit 4 min read React-Router Hooks React-Router is a popular React library that is heavily used for client-side routing and offers single-page routing. It provides various Component APIs( like Route, Link, Switch, etc.) that you can use in your React application to render different components based on the URL pathnames on a single pa 11 min read ReactJS useId Hook React useId Hook is introduced for the ReactJS versions above 18. This hook generates unique IDs i.e, returns a string that is stable across both the server and the client sides. Prerequisite: Introduction and installation of ReactJSReact Hooks Syntax: const id = useId() Creating React Application: 3 min read React Hooks ReactJS Hooks are one of the most powerful features of React, introduced in version 16.8. They allow developers to use state and other React features without writing a class component. Hooks simplify the code, make it more readable, and offer a more functional approach to React development. With hoo 10 min read React Hooks vs Redux React Hooks and Redux are tools in React that help manage state, but they work differently. React Hooks, are useState and useEffect through which allow each component to handle there own data. Redux, on the other hand, is a tool that stores all data in one place, making it easier to share data acros 3 min read ReactJs useDebugValue Hook React useDebugValue Hook is introduced for the ReactJs versions above 18. React useDebugValue Hook helps developers debug custom hooks in React Developer Tools by adding additional information and labels to those hooks. Prerequisite:ReactJSReact Developer ToolsReact HooksReact Custom HooksApproach:T 2 min read React useState Hook The useState hook is a function that allows you to add state to a functional component. It is an alternative to the useReducer hook that is preferred when we require the basic update. useState Hooks are used to add the state variables in the components. For using the useState hook we have to import 5 min read Like