Interview Q&A / React
React interview questions
Rendering, state, hooks, keys and effects, explained with small examples.
Prefer rapid revision? Practise React short interview answers →
- For a simple contact form, would you use controlled or uncontrolled inputs?
For a few fields that are only read on submit, uncontrolled inputs with FormData are enough and re-render less. Use controlled inputs when you need live validation, dependent fields, formatting as the user types or to disable the button.
IntermediateQuick answer1 min read - How do you read a file from an input type file in React?
File inputs are always uncontrolled. Read e.target.files in onChange, take the File object, and either upload it with FormData or preview it with URL.createObjectURL. You cannot set a file input's value from state.
IntermediateQuick answer1 min read - How would you validate a React form without a library?
Keep values and an errors object in state. Write a validate function that returns errors from the values, run it on submit (and optionally on blur), call preventDefault, and submit only when the errors object is empty.
IntermediateQuick answer1 min read - What does the useFormStatus hook do in React 19?
useFormStatus, from react-dom, reads the status of the parent form: whether it is pending, plus the submitted data. It must be called inside a component rendered within the form, which lets a submit button disable itself.
IntermediateQuick answer1 min read