Development

React Interview Questions and Answers

Prepare for React interviews with answers about components, props, state, hooks, rendering, keys, effects, context and performance.

React interview workspace showing a connected component hierarchy and state flow
Original concept artwork created for this Circuit Compass guide.

React interviews usually test whether you understand rendering and state, not whether you can recite hook names. Use these answers as explanations you can expand with code from your own projects.

Core React interview questions

1. What is a React component?

A component is a reusable unit that returns a description of UI from props and state. Modern React code generally uses function components.

2. Props vs state?

Props are inputs supplied by a parent. State is a component’s memory. Treat both as immutable snapshots during a render.

3. Why are keys important?

Keys identify siblings across renders so React can preserve the correct component state. Use stable data IDs, not a random value or an array index when order can change.

Hooks and effects

4. What does useState do?

It declares state and returns the current snapshot plus a setter that schedules another render. Use the updater form when new state depends on previous state.

5. When should you use useEffect?

Use an Effect to synchronize with an external system such as a network connection, browser API or third-party widget. Derived values usually belong in rendering rather than an Effect.

6. What does an Effect cleanup do?

Cleanup reverses the setup: unsubscribe, disconnect, cancel or clear. React runs it before the Effect reruns and when the component unmounts.

State and application design

7. What is lifting state up?

Move shared state to the nearest common parent and pass values and handlers down. This creates one source of truth for coordinated components.

8. When should Context be used?

Context passes information deeply without repeating props at every level. It fits themes, authentication context and shared configuration, but frequent broad updates can cause unnecessary rendering.

9. Controlled vs uncontrolled inputs?

A controlled input receives its value from React state. An uncontrolled input keeps its current value in the DOM and is commonly accessed with a ref or form submission.

Performance and interview practice

Measure before optimizing. Keep state local, avoid unnecessary Effects and use memoization only when it prevents meaningful work. In a coding interview, explain component boundaries, loading and error states, accessibility, stable keys and how you would test user-visible behavior.

Frequently asked questions

Is React a framework or library?

React describes itself as a library for web and native user interfaces. Full applications often add a framework for routing, data loading and build tooling.

What React topics matter most for interviews?

Rendering, props, state, events, keys, Effects, forms, context, accessibility and testing are the core areas.

Sources and further reading

Features, software and prices change. Confirm current details with these sources before making a decision.

Found something that needs updating? Send a correction with the page URL and a supporting source.