Skip to content
tezvyn:

Top 30 React Interview Questions and Answers

30 multiple-choice questions on React, drawn from 30 bites out of the 262 tagged React on Tezvyn. Answer them here or read straight down. Every question carries the correct option, why it is correct, and a link to the bite it came from.

30 questions. Pick an answer, or open “Show the answer” to read it.

Answers are graded in your browser. Nothing is saved, and no XP or streak is earned here. The app keeps score.

  1. Question 1 of 30

    Why can a standard browser not execute a .jsx file directly without a build step?

    Show the answer

    Answer: c · JSX must first be transpiled into React.createElement or jsx function calls

    JSX is syntax the JS engine does not understand, so a transpiler converts it to function calls first. Browsers never receive JSX; the CDN or MIME claims are irrelevant to the transpilation requirement.

    Read the full bite: What is JSX and how does the browser run it?

  2. Question 2 of 30

    How does Turbopack's Server Fast Refresh in Next.js 16.2 differ from the previous server-side reload behavior?

    Show the answer

    Answer: c · It reloads only the changed module and leaves the rest of the server process intact, rather than clearing the require.cache for the entire import chain.

    Turbopack now surgically reloads only the changed module while leaving the server process intact, replacing the old behavior of clearing require.cache for the changed file and its entire import chain. Option A is tempting because it mentions require.cache and node_modules, but the old system actually cleared untouched node_modules in the import chain, and the new approach avoids chain-wide cache clearing entirely.

    Read the full bite: Next.js 16.2 brings 67-100% faster server Fast Refresh

  3. Question 3 of 30

    What is the primary risk when React teams adopt TypeScript without standardized prop and hook typing patterns?

    Show the answer

    Answer: b · Code review slows due to style debates and type safety erodes from inconsistent patterns

    The card warns that poor typing leads to verbose code, suppressed errors, and code review debates about style rather than logic. Option C is wrong because ComponentProps is introduced to eliminate verbose manual re-declaration, not require it.

    Read the full bite: Matt Pocock's Free React TypeScript Tutorial

  4. Question 4 of 30

    What is the fundamental nature of a React Component?

    Show the answer

    Answer: d · A JavaScript function that returns a description of UI using JSX.

    The card explicitly states, "A React component is a JavaScript function that returns a piece of UI" and that it returns "JSX" to describe the UI. While components are analogous to custom HTML tags, their core implementation is a JavaScript function.

    Read the full bite: React Components: Your UI Building Blocks

  5. Question 5 of 30

    What happens when an AI agent tries to launch a second next dev process in Next.js 16.2?

    Show the answer

    Answer: b · Next.js emits a structured error that includes the exact kill command for the running process

    The dev server lock file at .next/dev/lock stores the PID, port, and URL, enabling Next.js to return a structured error with the precise kill command rather than a generic port-in-use message. Option A is tempting because some dev tools auto-restart, but Next.js 16.2 explicitly returns an error instead, and Option D confuses the lock file feature with the separate browser-to-terminal logging feature.

    Read the full bite: Next.js 16.2 adds agent-native dev tooling

  6. Question 6 of 30

    What is the fundamental nature of JSX in a React application?

    Show the answer

    Answer: d · It is a syntax extension that a build tool converts into standard JavaScript function calls.

    The card explains that JSX is a "syntax extension" that "gets compiled into plain JavaScript objects" by a "compiler (like Babel)" into "React.createElement() function calls." Option C is incorrect because the card explicitly states JSX is "not a string, nor is it HTML."

    Read the full bite: JSX: Putting HTML Inside Your JavaScript Components

  7. Question 7 of 30

    A child component needs to change a value it received from its parent. What is the correct React pattern?

    Show the answer

    Answer: c · Call a callback function passed down from the parent via props

    Props are immutable and flow one-way from parent to child, so the child must invoke a callback prop to request that the parent update the data. Mutating a prop directly breaks React's rendering assumptions and will not trigger a re-render.

    Read the full bite: Explain props in React and how parent components pass data to children

  8. Question 8 of 30

    Which accurately describes the two primary ways to define a React component?

    Show the answer

    Answer: c · Function components and class components, with function components being the standard for new React 19 code

    Function components and class components are the two distinct definition paradigms, and function components are the React 19 default. Arrow functions and function declarations are merely alternate syntaxes for the same function component paradigm, not separate ways to define components.

    Read the full bite: What are the two main ways to define a component in React?

  9. Question 9 of 30

    Which statement accurately describes a core principle of how React components should handle props?

    Show the answer

    Answer: b · Props facilitate a one-way data flow, allowing data to be passed from parent to child components.

    The card states that props establish a 'clear, one-way data flow from parent components to child components.' This ensures predictability and reusability. Option A is incorrect because a component should never modify the props it receives; that's what state is for.

    Read the full bite: React Props: Arguments for Your Components

  10. Question 10 of 30

    What is the main advantage of using a React Fragment (e.g., <></>) over a <div> when a component needs to return multiple elements?

    Show the answer

    Answer: d · Fragments prevent the addition of an unnecessary wrapper DOM node, maintaining cleaner HTML structure.

    React Fragments are designed to group multiple elements for React's internal processing without adding an extra DOM node to the final HTML, which is essential for valid HTML structures and avoiding unwanted styling issues. Fragments themselves do not add a DOM node, so they cannot have CSS classes or event listeners applied to them directly.

    Read the full bite: React Fragments: Group Elements Without a Wrapper

  11. Question 11 of 30

    When a dynamic list reorders and items have local state, what happens if array indices are used as React keys?

    Show the answer

    Answer: d · React reuses component instances by position, causing state from one data item to appear on another.

    Array indices tie identity to position, so React reuses the wrong component instance after reorder or deletion and state ends up attached to the wrong data item. Option B is wrong because React does not reset state when keys are unstable—it incorrectly preserves it on the reused instance.

    Read the full bite: What is the purpose of React's key prop and index key risks?

  12. Question 12 of 30

    What is the immediate effect when a useState setter function, like setCount(count + 1), is invoked?

    Show the answer

    Answer: c · React schedules a re-render of the component with the new state value.

    Calling a useState setter function tells React to schedule a re-render with the new state value, as stated by 'React schedules a re-render.' The 'count' variable in the current render's scope does not update immediately; this is a common 'footgun' where the new value is only available on the next render.

    Read the full bite: useState: Giving Components Memory

  13. Question 13 of 30

    In React, when is an early return with if/else preferable to an inline ternary inside JSX?

    Show the answer

    Answer: a · When branches are large, structurally different, or to reduce nesting

    Early returns improve readability when branches are large, structurally different, or deeply nested. Option B actually describes when an inline ternary is the better choice, not an early return.

    Read the full bite: Describe two patterns for conditional rendering in JSX

  14. Question 14 of 30

    Why would wrapping two table cells in a Fragment be preferable to wrapping them in a div?

    Show the answer

    Answer: a · Fragments avoid creating an invalid HTML structure since they do not add an extra DOM node.

    A div placed directly inside a table row creates invalid HTML, while a Fragment groups children without introducing any DOM node. Claiming a performance benefit is a common misconception; the primary reason to use Fragments is structural and semantic correctness, not optimization.

    Read the full bite: What is a React Fragment and why use it over a div?

  15. Question 15 of 30

    What is the primary issue with using `onClick={myFunction()}` instead of `onClick={myFunction}` in a React component?

    Show the answer

    Answer: c · It executes `myFunction` immediately during the component's render phase, not when the user clicks.

    The card explicitly states that `onClick={handleClick()}` is incorrect because "The parentheses () execute the function immediately during the component's render phase." This means the function runs when the component is drawn, not when the user interacts with it. Option D is incorrect because it's a logical error, not a syntax error.

    Read the full bite: React Events: Pass, Don't Call

  16. Question 16 of 30

    What is the most comprehensive approach to accurately track page views in a Single Page Application (SPA)?

    Show the answer

    Answer: a · Implement both framework-specific router hooks for internal navigation and a window.popstate listener for browser back/forward actions.

    A complete solution for tracking SPA page views requires handling two distinct scenarios: programmatic navigation (e.g., clicking internal links) via framework router hooks, and browser-driven navigation (e.g., back/forward buttons) via the window.popstate event. Option D is a tempting distractor because while popstate is crucial for browser history buttons, it does not fire for programmatic navigation using pushState or replaceState, making it an incomplete solution.

    Read the full bite: How do you track page views in a Single Page Application?

  17. Question 17 of 30

    A team passes a user object through Layout, Header, Navigation, and finally to UserMenu. What is the strongest argument for replacing this with Context or composition?

    Show the answer

    Answer: a · Layout, Header, and Navigation are coupled to a prop they ignore, making refactors and reuse harder.

    Prop drilling is primarily a maintenance and coupling problem: intermediaries must accept and forward props they do not use, so renaming the prop or reusing those components elsewhere becomes painful. Option B is tempting but wrong because the card explicitly warns against confusing drilling with runtime performance issues like excessive re-renders.

    Read the full bite: Explain prop drilling and why it's a problem

  18. Question 18 of 30

    When using the logical AND operator (condition && <Component />) for conditional rendering in React, what is a crucial behavior to be aware of?

    Show the answer

    Answer: d · If 'condition' evaluates to 0, the number 0 might be displayed in the UI.

    The card explicitly mentions this as a 'footgun': if 'condition' is the number 0, the expression '0 && <Component />' evaluates to 0, which React will render. Option C is incorrect because JavaScript's logical AND operator works with any truthy or falsy value, not just strict booleans.

    Read the full bite: Conditional Rendering: Show UI Based on State

  19. Question 19 of 30

    To reliably track navigation as 'page views' in a Single Page Application, what is the most appropriate client-side strategy?

    Show the answer

    Answer: c · Listen for `popstate` events and hook into the router's history object to detect navigation and send tracking events.

    This is correct because it covers both programmatic navigation (via the router's history) and browser button navigation (via `popstate`). Polling with `setInterval` is a tempting but grossly inefficient anti-pattern.

    Read the full bite: How do you track page views in a Single Page Application?

  20. Question 20 of 30

    Which call reflects how Babel transforms the JSX <a href='/home' className='link'>Go Home</a> into React.createElement()?

    Show the answer

    Answer: b · React.createElement('a', {href: '/home', className: 'link'}, 'Go Home')

    The JSX transform emits a quoted string for lowercase host tags, places attributes in the second argument preserving className, and passes text children as the third argument, not inside props. Option A is tempting because the resulting element object has props.children, but the createElement API signature requires children as a separate argument from props.

    Read the full bite: Write the React.createElement() equivalent for this JSX

  21. Question 21 of 30

    When rendering a dynamic list, what problem does the key prop solve if items are later reordered or filtered?

    Show the answer

    Answer: b · It provides a stable identifier so React can distinguish individual elements as the collection changes

    The key acts as a stable name tag so React can tell one output from another when items shift, disappear, or join the line. Preventing console warnings is only a side effect of adding keys, not their core purpose.

    Read the full bite: Lists and Keys in React

  22. Question 22 of 30

    Why can using array indices as keys cause state pollution when a list is reordered?

    Show the answer

    Answer: d · React relies on keys to identify elements across renders; indices make React match DOM nodes to the wrong data, preserving state for the wrong item.

    Keys provide sibling-scoped identity, not just a performance shortcut; when indices are reused after reordering, React incorrectly associates the old DOM node and its state with new data. Option A is wrong because keys fundamentally determine state preservation, so unstable keys create correctness bugs rather than merely slower reconciliation.

    Read the full bite: How does React use keys in reconciliation? When do keys cause bugs?

  23. Question 23 of 30

    Which of the following best describes the primary role of React's useEffect hook?

    Show the answer

    Answer: a · To synchronize the component with external systems like APIs or browser events.

    The primary role of useEffect is to synchronize a component with systems outside React's control, such as fetching data from an API or subscribing to browser events. It is explicitly stated not to be used for data transformation or handling user events, which are managed differently.

    Read the full bite: useEffect: Syncing React with the Outside World

  24. Question 24 of 30

    What is the key architectural difference between passing a render function prop and passing a component reference prop in React?

    Show the answer

    Answer: a · A render function is called by the child with internal data, letting the parent control what renders while the child controls when and where.

    This captures inversion of control: the parent supplies the function (what to render) and the child invokes it with internal data (when and where). Option D is tempting because both patterns enable reuse, but HOCs wrap components at definition time while render props compose at runtime.

    Read the full bite: Can you pass a React component as a prop? Explain Render Props.

  25. Question 25 of 30

    When decomposing a UI into React components, what is the most crucial principle to follow for effective design?

    Show the answer

    Answer: d · Adhering to the single responsibility principle, where each component does one thing.

    The card emphasizes that "a good guideline is the single responsibility principle: a component should ideally do only one thing" to avoid "god components." While other options might be considerations, they are not the primary principle for decomposition itself.

    Read the full bite: Thinking in React: Decomposing UIs into Components

  26. Question 26 of 30

    Which pattern correctly wires a text input as a controlled component using useState?

    Show the answer

    Answer: a · Initialize useState with an empty string at the top level, bind the input value to the state variable, and update it via onChange by calling the setter with event.target.value.

    The correct pattern requires calling useState at the top level with an empty string, binding the input value to state, and updating via the setter in onChange. Option C is tempting because it mentions binding value, but calling useState conditionally violates the Rules of Hooks and direct mutation prevents React from re-rendering.

    Read the full bite: How do you use useState to track user input?

  27. Question 27 of 30

    What happens to a useEffect's cleanup and setup when a value in its dependency array changes?

    Show the answer

    Answer: a · React runs the previous cleanup with old values first, then runs setup with the new values

    React always runs the previous effect's cleanup with the old dependency values before running the new setup when a dependency changes. The most tempting distractor is wrong because cleanup is not reserved for unmount; it runs whenever dependencies change to prevent stale subscriptions or leaks.

    Read the full bite: Explain useEffect dependency array behavior for [], [deps], and omitted

  28. Question 28 of 30

    In a React component, for which scenario would using a ref be the most appropriate choice over state?

    Show the answer

    Answer: a · Holding an interval ID returned by setInterval that needs to be cleared later.

    Refs are ideal for storing mutable values that persist across renders without triggering UI updates, such as an interval ID that is never displayed. Options A, C, and D all involve data that directly affects the UI, requiring state to ensure re-renders when the values change.

    Read the full bite: React Refs: Memory Without Re-renders

  29. Question 29 of 30

    You need to increment a React state variable three times within a single event handler. Which approach produces the correct final value?

    Show the answer

    Answer: c · Call setCount(prev => prev + 1) three times sequentially

    Option C uses the functional updater so React queues each increment against the latest pending state. Option B fails because all three calls read the same closed-over value from the render snapshot, so each computes 0 + 1.

    Read the full bite: What will count be after three setCount calls in a row?

  30. Question 30 of 30

    When creating a WelcomeDialog component that uses a generic Dialog component to display a fixed title and message, which approach best exemplifies React's "favor composition" principle?

    Show the answer

    Answer: b · WelcomeDialog renders the Dialog component internally, passing it specific title and message props.

    The card states that for specialization, a more specific component simply renders a more generic one and configures it with props, as exemplified by WelcomeDialog rendering Dialog. Option C uses class inheritance, which the card explicitly advises against for UI component hierarchies.

    Read the full bite: React's Rule: Favor Composition Over Inheritance

Could you explain these out loud?

That is what an interview actually tests. Tezvyn gives you questions like these with what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon