React interview questions

12 questions, easy to hard. Read one, then answer it out loud: an AI interviewer follows up, hints when you're stuck and grades your answer.

React interviews focus on how components think: state and props, rendering, effects, hooks and keeping an interface fast.

React

  1. You're explaining React to someone who knows HTML and JavaScript but has never used it. They ask: what is a component, and what is JSX? Walk them through how you'd build a greeting card that shows a person's name, and how you'd reuse it for three different people.

    What a strong answer covers
    • What a component is in plain terms.
    • What JSX is, what it turns into, and how it differs from HTML.
    • Passing data in so one component can show different people.
    • Naming and return conventions that trip up beginners.

    Common mistake: Describing JSX as HTML that React sends to the browser, rather than JavaScript that describes the UI.

  2. A like button shows a heart and a count of likes. Clicking it adds one to the count. The button's label text is chosen by the page that uses it. Explain which of these values should be props and which should be state, and what happens on screen when the button is clicked.

    What a strong answer covers
    • How to tell data handed in from data a component owns.
    • Which of the button's values belongs in each category.
    • What actually causes the screen to update after a click.
    • Who is allowed to change props.

    Common mistake: Changing a variable or object directly and expecting React to notice.

  3. You have an array of to-do items, each with an ID and some text, and you need to show them as a list. Explain how you'd render it in React, why React warns about a missing key prop, and what could go wrong if you used each item's position in the array as its key.

    What a strong answer covers
    • Turning an array of data into a list of elements.
    • What keys let React keep track of between renders.
    • A good source for each key.
    • What goes wrong when keys are based on position.

    Common mistake: Using the array position as the key, so state ends up attached to the wrong item after a change.

  4. A page has two sibling components: a search box and a results list. Each keeps its own copy of the search text in state, so typing in the box doesn't update the list. Explain how you would restructure the components so the list always shows results for what's typed in the box.

    What a strong answer covers
    • Where the shared value should live so both components see the same thing.
    • How the value travels down and how changes travel back up.
    • Why a single source of truth fixes the mismatch.
    • Options when the components are far apart in the tree.

    Common mistake: Trying to keep the two copies in sync with each other instead of having one owner.

  5. You're building a sign-up form in React with a name field and a newsletter checkbox, and the submit button should only be enabled once the name isn't empty. Explain how you'd wire the inputs to state, and what a controlled input is.

    What a strong answer covers
    • Connecting each input's displayed value to state.
    • Updating that state as the user types or ticks.
    • What makes an input controlled, and why that gives one source of truth.
    • Working out the button's enabled state rather than storing it, and alternatives to controlled inputs.

    Common mistake: Keeping a separate piece of state for whether the button is enabled, which can fall out of step with the name.

  6. A shopping cart component should show a loading message, an error, an empty-cart message, or the list of items. A colleague's version sometimes shows a stray zero on the page. Explain how you'd render each case, and where the zero comes from.

    What a strong answer covers
    • Clean ways to choose between several mutually exclusive states.
    • Where the stray zero comes from in short-circuit rendering.
    • Rewriting the condition so it can't leak a number.
    • Rendering nothing on purpose, and ordering the checks.

    Common mistake: Assuming React skips every falsy value, when it renders the number zero.

  7. A component shows a counter that should go up by one every second. It keeps the count in state, and an effect with an empty dependency list starts an interval that sets the count to the current count plus one. On screen, the counter goes from zero to one and then stays at one. Explain why, and how you'd fix it.

    What a strong answer covers
    • Why the interval keeps seeing the first value.
    • What the effect's dependencies have to do with it.
    • Ways to update the count that don't depend on the stale value.
    • Cleaning up the interval.

    Common mistake: Adding the count as a dependency but forgetting the cleanup, so intervals pile up.

  8. A component stores a list of items and a filter, and uses an effect to copy the filtered list into a third piece of state whenever either changes. The screen flickers with stale results for a moment. Explain what's wrong and how you'd simplify it.

    What a strong answer covers
    • Why copying derived data through an effect shows stale results first.
    • Working the value out during render instead of storing it.
    • When caching the calculation is worth it.
    • What effects are genuinely for.

    Common mistake: Reaching for an effect whenever one value depends on another.

  9. A profile page fetches a user in an effect whenever the user ID prop changes. When you click quickly between profiles, sometimes the wrong user's data appears. Explain why, how you'd fix it, and when you'd reach for a data-fetching library instead.

    What a strong answer covers
    • Why responses can arrive out of order when the ID changes quickly.
    • Using cleanup to discard or cancel outdated requests.
    • Loading, error and dependency handling.
    • When a data-fetching library or framework feature is the better choice.

    Common mistake: Assuming responses arrive in the order requests were sent.

  10. The current user and theme are passed as props through six layers of components that don't use them, just to reach a few deep ones. Explain how React context would help, how you'd set it up, and the costs of using it.

    What a strong answer covers
    • What prop drilling costs and how context avoids it.
    • Providing a value high up and reading it deep down.
    • The re-rendering cost of context and how to contain it.
    • Alternatives, and why context isn't a home for all state.

    Common mistake: Putting everything into one context object that changes often, so every consumer re-renders.

  11. Three components each track the window's width with their own state, effect and resize listener, copied and pasted. Explain how you'd extract a custom hook for this, and what rules hooks must follow.

    What a strong answer covers
    • What a custom hook is and how it's named.
    • Setting up and tearing down the listener inside it.
    • Whether components using the same hook share state.
    • The rules all hooks must follow, and why.

    Common mistake: Expecting a custom hook to share one piece of state between every component that calls it.

  12. A page has a filter text box above a list of ten thousand products. The parent component holds the filter text in state, filters the products on every render, and renders every matching row. Typing in the box feels laggy: each keystroke takes hundreds of milliseconds. Explain how you would find the cause and make typing feel instant.

    What a strong answer covers
    • Measuring which components render and how long they take before changing anything.
    • Cutting renders that don't need to happen.
    • Rendering fewer rows at a time.
    • Keeping typing responsive while the expensive update catches up.
    • The costs of these techniques and when the work belongs elsewhere.

    Common mistake: Wrapping everything in memoisation without profiling, adding cost without fixing the real bottleneck.

Questions about practising

How should I prepare for react interview questions?
Practise answering them out loud, not just reading them. Explaining an answer under follow-up questions is what interviews test. Work through the 12 questions here from easy to hard, and revisit the ones you struggle with.
Can I practise react interview questions with an AI?
Yes. Open any question and start a voice session: an AI interviewer asks it, follows up on your answer, gives hints when you're stuck and grades your answer with written feedback when the call ends.
Are these react interview questions free?
1 of the 12 questions are free to practise. Sign in with Google, no card needed. Pro unlocks the rest, plus practice calls to your phone.