Interview Q&A / React

INTERVIEW Q&A · 58 QUESTIONS

React interview questions

Rendering, state, hooks, keys and effects, explained with small examples.

  1. What is the difference between controlled and uncontrolled components in React?

    In a controlled component, React state holds the input's value and every change goes through an onChange handler. In an uncontrolled component, the browser DOM keeps the value and you read it when needed, for example with a ref or from the form data on submit.

    BeginnerIn-depth3 min read
  2. How do you manage several form fields with a single state object?

    Store the fields in one object and give each input a name attribute. One onChange handler reads e.target.name and e.target.value and updates that key with computed property syntax, copying the rest with spread.

    BeginnerQuick answer1 min read
  3. Why does a controlled input stop accepting typing in React?

    A controlled input shows exactly what its value prop says. If you set value without an onChange that updates state, React keeps resetting it to the old value, so the field looks frozen and also warns in the console.

    BeginnerQuick answer1 min read