Q11. How does useContext works? Explain with an example
The `useContext` hook can be used for authentication state management across multiple components and pages in a React application. Let's build a simple authentication flo...
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 (25 available).
The `useContext` hook can be used for authentication state management across multiple components and pages in a React application. Let's build a simple authentication flo...
Yes, it is possible. You can use multiple contexts inside the same component by calling useContext multiple times, once for each context. It can be achieved with below st...
A **common pitfall** when using `useContext` with objects is **triggering unnecessary re-renders** across all consuming components — even when only part of the context va...
When a component calls `useContext(SomeContext)` but **no matching** `` **is present higher up in the component tree**, the **default value** passed to `React.createConte...
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...
**No.** `React.memo` only performs a shallow comparison of a component's **props** — it has no visibility into context. If a component reads a value via `useContext`/`Con...
A **reusable Context** bundles the `createContext` call, its `Provider` (with local state/logic), and a custom hook to consume it into a single module. This hides the raw...
_Context_ provides a way to pass data through the component tree without having to pass props down manually at every level. For example, authenticated users, locale prefe...
**⚠️ LEGACY:** This question is only relevant for historical context. React v15 is extremely outdated (released in 2016). React v15 provided very basic support for _error...
**⚠️ DEPRECATED:** `componentWillMount()` has been removed in React 17+. This question is only relevant for legacy React applications. **Historical Context:** While it wa...
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.