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 →
- What is the difference between state and props in React?
Props are inputs passed into a component by its parent and are read-only inside it. State is data a component owns and can change over time, and changing it makes the component re-render.
BeginnerIn-depth3 min read - Can a child component modify the props it receives?
No. Props are read-only; React treats them as immutable snapshots from the parent. To change a value, the parent passes down a callback, and the child calls it so the parent updates its own state.
BeginnerQuick answer1 min read - How do you give a prop a default value in a modern function component?
Use default values in the destructured parameters, such as function Badge({ color = 'blue' }). The default applies only when the prop is undefined, not when it is null or an empty string.
BeginnerQuick answer1 min read - What is the children prop in React, and when is it useful?
children is the content placed between a component's opening and closing tags. It lets a component wrap whatever the caller supplies, which is how layouts, cards and modals stay reusable.
BeginnerQuick answer1 min read