Q321. How do you share state logic between components using custom hooks?
Custom hooks allow you to **extract and share stateful logic** between components without changing their hierarchy. The state itself is not shared—each component using th...
Technical Question Bank · Peer-Reviewed
Search and filter frequently asked interview questions across technical, programming, and behavioral domains. Tailor your interview preparation by difficulty for freshers or experienced developers (454 available).
Custom hooks allow you to **extract and share stateful logic** between components without changing their hierarchy. The state itself is not shared—each component using th...
The `useDebugValue` hook is used to **display a label** for custom hooks in **React DevTools**. It helps developers debug custom hooks by showing meaningful information. ...
The cleanup function in `useEffect` is used to **clean up side effects** before the component unmounts or before the effect runs again. This prevents memory leaks, stale ...
`useEvent` is an **experimental hook** (not yet stable in React) designed to solve the problem of creating **stable event handlers** that always access the latest props a...
Following best practices ensures your hooks are predictable, maintainable, and bug-free. #### 1. **Follow the Rules of Hooks** - Only call hooks at the top level (not ins...
React 18, released in March 2022, introduced several groundbreaking features focused on performance and user experience: #### 1. **Automatic Batching** Batch multiple sta...
React 19 (released 2024) brings major improvements for full-stack React applications: #### 1. **React Compiler (formerly React Forget)** Automatic memoization - no more m...
The `use()` hook allows you to read the value of a resource (Promise or Context) during render, with Suspense integration. #### Reading Promises ```jsx import { use, Susp...
**Server Actions** allow you to call server-side functions directly from client components without writing API endpoints. #### Basic Server Action ```jsx // app/actions.j...
These hooks simplify form handling with Server Actions in React 19. #### useFormState Manages form state and handles server responses: ```jsx 'use client' import { useFor...
HireXTech uses essential storage to remember your study preferences and third-party advertising cookies via Google AdSense in compliance with GDPR. You can choose to enable essential cookies only or accept all cookies. Read our Privacy Policy.