What is the virtual DOM in React and how does it work?
The virtual DOM is a lightweight JavaScript copy of the UI that React compares with the previous version after each update, so it only changes the parts of the real DOM that actually differ.
Frontend 路 Intern to senior
React questions test whether you understand how components render and update, not just whether you can build a form. Interns are asked about props, state and hooks; mid-level and senior candidates are asked why a component re-renders, how to prevent wasted work and how rendering strategies affect performance and SEO.
7 of 12 questions match
Clear filtersThe virtual DOM is a lightweight JavaScript copy of the UI that React compares with the previous version after each update, so it only changes the parts of the real DOM that actually differ.
Props are read-only inputs passed from a parent component, while state is data a component owns and can change over time, which triggers a re-render when updated.
Hooks are functions such as useState and useEffect that let function components use state, lifecycle behaviour and other React features; they must be called at the top level of a component or custom hook, never inside loops, conditions or nested functions.
Keys give each list item a stable identity so React can match items between renders and correctly add, remove or reorder them without recreating or mixing up their state.
useEffect runs a function after the component renders; the dependency array tells React when to re-run it: with no array it runs after every render, with an empty array only after the first, and with values only when those values change.
A controlled component keeps the input's value in React state and updates it through onChange, while an uncontrolled component lets the DOM hold the value and you read it with a ref when needed.
Prop drilling is passing props through several layers of components that do not use them just to reach a deeply nested child; you avoid it with composition, the Context API or a state management library.