AI Hints
Home›React Tutorial›Interview Prep and Final Quiz
React · Lesson 115 of 120

React Interview Questions

Part one.

⏱ 2 min read▶ Video at 1:34:57🎓 Free
Watch this lesson in the React courseWatch on YouTube ↗Full React course

React interviews tend to ask the same core questions. Let's answer the most common ones, short and clear.

  • Same questions
  • Core ideas
  • Short answers

What is the virtual DOM?

React keeps a lightweight description of the page. When state changes, it builds a new description, compares it with the old one, and updates only what changed in the real page. That comparison is called reconciliation.

keyvalue
Describethe UI as objects
Compareold vs new
Updateonly what changed
Namereconciliation

Why do lists need keys?

Keys tell React which item is which between renders. With stable keys, React can move, add, or remove items correctly. Using the array index breaks this when the list is reordered.

keyvalue
Purposeidentify items
Gooda stable id
Badthe index, if order changes
Effectcorrect updates

Props versus state

Props are passed in by the parent, and are read only. State belongs to the component, and changes over time with its setter. Both cause a re-render when they change.

keyvalue
Propsfrom the parent
Props areread only
Stateowned, changes
Bothtrigger renders

Summary

Virtual DOM, keys, and props versus state are the classics. Next, more interview questions.

Key takeaways
  • Reconciliation
  • Keys
  • Props vs state
Next up: More Interview Questions — part two