
Hooks are special functions introduced in React 16.8 that allow you to "hook into" React state and lifecycle features from functional components. Before hooks, managing state and side effects in React components typically required using class components. Hooks provide a way to achieve the same functionality within simpler functional components.
Most Common Basic Hooks
Hook | Use |
---|---|
useState() | Add state to function components |
useEffect() | Handle side effects (e.g., API call, DOM updates) |
useRef() | Create mutable reference (like instance variables) |
useContext() | Access global/shared data using context |
Advanced Hooks in React
Hook | Purpose |
---|---|
useReducer() | Manages complex state logic (like Redux) |
useCallback() | Memoizes functions to avoid re-creation on re-renders |
useMemo() | Memoizes values to prevent expensive recalculations |
useLayoutEffect() | LikeuseEffect but runs synchronously after DOM updates |
useImperativeHandle() | Customize the refpassed to a child component |
useDebugValue() | Show custom labels in React DevTools |
useDeferredValue() | Improve performance during input rendering |
useTransition() | Mark UI updates as non-urgent to prevent UI blocking |
See More Related Blog
what is UseSelectore Hook and UseDispatch Hook
-
- by Mcs
useSelector and useDispatch are custom React Hooks provided by the react-redux library, designed to simplify interaction with a Redux store within React functional…
what is Redux ?
-
- by Mcs
Redux is a state management library used with React (or any JavaScript app) to manage the application's global state in a predictable way.
Filtering, Searching, and Sorting in React
-
- by Mcs
Filtering, searching, and sorting are essential data manipulation techniques in React applications that enhance user experience by allowing users to easily find and…
What is Router in React ?
-
- by Mcs
React Router is the standard routing library for React. It allows your app to behave like a multi-page app by enabling navigation between different components without…
what is crud operation in react js ?
-
- by Mcs
In React.js, CRUD stands for Create, Read, Update, and Delete — the four basic operations for managing data in web applications. These operations usually involve…
what is Custom Higher-Order Components (HOC) ?
-
- by Mcs
A Higher-Order Component is a function that takes a component and returns a new component with enhanced or additional behavior.
Form Handling in React
-
- by Mcs
In React, form handling means capturing user input from form fields like <input>, <textarea>, <select>, etc., and managing the data using state.
what is Fragments in React ?
-
- by Mcs
A Fragment lets you group multiple elements without adding extra nodes to the DOM (like a <div>).
what is Lists & Keys in React ?
-
- by Mcs
In React, lists are used to display multiple elements dynamically (like items, users, products). When rendering lists, you must use keys to help React track and update…
what is React Events ?
-
- by Mcs
In React, events work just like in HTML/JavaScript — but with a few differences to make them more powerful and consistent across browsers.
what is useTransition ?
-
- by Mcs
useTransition() is a React Hook that helps you mark state updates as “non-urgent” so the UI stays responsive — even during slow renders.
what is usedeferredvalue ?
-
- by Mcs
useDeferredValue() is a React Hook used to delay updating a value until the browser is less busy, helping improve performance and UI responsiveness — especially in input…
what is useDebugValue ?
-
- by Mcs
useDebugValue() is a React Hook used to label custom hooks in React DevTools — making it easier to debug and understand the hook's state during development.
what is useImperativeHandle() ?
-
- by Mcs
useImperativeHandle() is a React Hook used with forwardRef() to customize the instance value (i.e. what a parent can access) when it uses a ref on a child component.
what is useLayoutEffect ?
-
- by Mcs
useLayoutEffect() is a React Hook that works just like useEffect() — but it runs synchronously after all DOM mutations and before the browser paints the screen.
what is usememo ?
-
- by Mcs
useMemo() is a React Hook that lets you memoize (cache) a computed value so it's not recalculated on every render unless its dependencies change.
what is useCallback() ?
-
- by Mcs
useCallback() is a React Hook used to memoize functions, so they are not re-created on every re-render unless necessary.
What is useReducer ?
-
- by Mcs
useReducer() is a React Hook used to manage complex state logic in function components.
what is useContext() ?
-
- by Mcs
useContext() is a React Hook that enables functional components to subscribe to and read context values. It provides a way to access data that is shared across the…
what is useRef() ?
-
- by Mcs
useRef is a React Hook that provides a way to create a mutable reference to a value or a DOM element that persists across component renders without triggering re-renders.
what is useEffect() ?
-
- by Mcs
useEffect is a React Hook that allows functional components to perform side effects, such as data fetching, subscriptions, or manually updating the DOM. It's…
what is useState() ?
-
- by Mcs
The React useState Hook allows us to track state in a function component. State generally refers to data or properties that need to be tracking in an application.
Function vs Class Components in React
-
- by Mcs
React offers two primary ways to create components: Function Components and Class Components. While both achieve the same goal of rendering UI, they differ significantly…
Fundamentals of React
-
- by Mcs
React is a JavaScript library for building user interfaces, and understanding its fundamentals is crucial for developing efficient and interactive web applications. Key…
Environment of ReactJS
-
- by Mcs
To work with ReactJS, you need to set up a proper development environment. Below are the tools and options you can use to start building React apps.
Array and Object handling in react js
-
- by Mcs
In React, arrays and objects are essential for: Storing and displaying data, Managing state with useState, Building dynamic and reusable UI components.
What is React ?
-
- by Mcs
React is a JavaScript library for building user interfaces — especially single-page applications (SPAs). It was developed by Facebook and is used to create fast,…
@ Mcs. All rights reserved
Comments
Add new comment