Skip to content
tezvyn:

React

262 bites tagged React — interview questions with model answers, and 60-second explainers.

React & Next.js2 min read

What is a Fiber in React Fiber architecture?

Tests reconciler internals. Strong answers define a Fiber as a unit of work with child, sibling, return, and alternate pointers; explain the linked-list tree enables incremental traversal; and note alternate connects current and work-in-progress trees.

React & Next.js2 min read

How does React batch multiple setState calls in one event handler?

Tests your grasp of React batching and stale closures. React queues updates until the handler exits, so multiple literal setState calls with the same stale value update once, while updater functions queue sequentially.

React & Next.js2 min read

Why is Fiber's render phase interruptible but commit is not?

Render calculates changes on invisible tree; commit runs DOM mutations and lifecycles synchronously. Knowledge that Fiber's render phase computes the workInProgress tree while commit applies side-effects.

React & Next.js2 min read

Why did React replace the Stack Reconciler with Fiber?

Tests React scheduling limits. Good answers note the old reconciler was synchronous and recursive, blocking the main thread, while Fiber enables incremental rendering and interruptible work. Red flag: citing Hooks or vague speed claims without frame budgets.

React & Next.js2 min read

Describe React's diffing algorithm and its O(n) heuristics

Different types unmount and rebuild; same types patch attributes and recurse; keys hint stable identity for children. Why React skips O(n³) diffing for heuristics and the cost.

React & Next.js2 min read

What are keys in React lists and why are they important?

Whether you understand React's reconciliation identity tracking. Keys are unique identifiers that let React match items across renders, preserving DOM state and avoiding unnecessary recreation.

React & Next.js2 min read

Describe a robust automatic token refresh strategy in a React SPA

This tests token rotation without UX interruption in SPAs. Use HttpOnly cookies for refresh tokens, in-memory access tokens, an interceptor with a promise lock, and proactive background refresh.

React & Next.js2 min read

How do you handle user-specific content on a getStaticProps page?

Tests the static generation boundary. A strong answer serves a static shell, then hydrates user state client-side via useEffect or SWR. Red flag: claiming getStaticProps can read cookies at build time.

React & Next.js2 min read

How would you implement a basic protected route in React?

Hold auth in useState, pass user to protected components, and return Navigate to login when absent. Whether you can gate React Router 7 routes declaratively.

React & Next.js2 min read

Implement a custom next/image loader for a self-hosted service

Tests next/image loader contract and URL construction. A strong answer defines a function taking src, width, and quality; returns a URL string for your service; and wires it via the loader prop or loaderFile config.

React & Next.js2 min read

Explain how next/image's sizes prop works for responsive performance

This tests your knowledge of the browser responsive image algorithm. The sizes prop declares the rendered width at each breakpoint so the browser can select the smallest adequate srcset candidate.

React & Next.js2 min read

Where Next.js Middleware executes and Edge Runtime limits

Tests your grasp of Edge Runtime constraints. Middleware runs at the Edge before route matching, with no Node.js APIs, require, Buffer, or dynamic eval, only Web APIs. Red flag: treating it as Node.js and suggesting fs or npm packages.

React & Next.js2 min read

What are the benefits of next/image over a standard img tag?

Tests knowledge of Next.js image infrastructure. Strong answers mention automatic optimization, lazy loading, blur placeholders for layout shift, and responsive srcset. Red flag: calling it a zero-impact wrapper or a styling component.

React & Next.js2 min read

Explain streaming with Server Components, Suspense, and loading.js

Tests progressive HTML streaming through Suspense boundaries. Strong answers state loading.js auto-wraps a route segment in Suspense so the server can stream the shell instantly and defer slow data without blocking first paint.

React & Next.js2 min read

How would you structure client-side data fetching in Next.js?

Tests when client fetching is needed in Next.js App Router. A strong answer marks the component with "use client" and fetches in useEffect or via SWR. It also handles loading, error, and race conditions.

React & Next.js2 min read

How does Server Component fetching differ from getStaticProps and getServerSideProps?

This tests shifting from page-level fetching to component-level async fetches. Strong answers note async await inside components, zero prop drilling, streaming, and mixed static or dynamic data. Red flag: calling them a simple rename of getServerSideProps.

React & Next.js2 min read

How do you implement SSR in Next.js App Router and configure fetch?

Tests App Router static defaults and fetch-driven dynamic rendering. Strong answer: async Server Component awaits fetch with cache no-store or next revalidate zero to force request-time rendering. Red flag: citing getServerSideProps or useEffect data fetching.

React & Next.js2 min read

How do you fetch data for SSG in a Next.js Server Component?

This checks if you know Server Components fetch at build time for static routes. A strong answer uses native fetch in an async Server Component, caches into static HTML, and shows a page.js snippet. A red flag is mentioning getStaticProps or useEffect.

React & Next.js2 min read

Key difference between Server and Client Components in Next.js?

Tests App Router rendering boundaries. A strong answer contrasts server-only execution against browser interactivity, choosing Client Components only for state, effects, or events.

React & Next.js2 min read

Server Component fetch vs. client-side SWR or React Query

Tests App Router cache boundaries and hydration costs. Strong answers weigh server TTFB and bundle savings against client interactivity, mutations, and background refetching. Red flag: defaulting to client fetching everywhere and ignoring waterfalls.

React & Next.js2 min read

How do nested layouts work in the App Router?

Tests nested layout composition and state persistence in the App Router. Good answers explain root wraps dashboard wraps page, dashboard state survives child navigation, and only the page segment rerenders.

React & Next.js2 min read

What are Next.js Route Groups and a practical use case?

Tests App Router conventions organizing routes without changing URLs. A good answer names parenthesized folders like (shop) removed from the path, cites multiple layouts per section, and keeps URLs clean. Red flag: confusing them with dynamic [slug] segments.

React & Next.js2 min read

What is layout.js and how does it differ from shared headers?

Layout.js persists across navigations without remounting; a shared header in each page.js remounts and loses state. App Router state preservation and nesting. calling them identical or only citing DRY.

React & Next.js2 min read

How do you create a /dashboard route in Next.js App Router?

Tests App Router file-system routing and the page.js convention. Good answer: create app/dashboard/page.js with a default export, note that only page.js creates an addressable route, and layouts do not.

Get React bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.