React Interview Questions & Answers
12. What is the difference between HTML and React event handling?
Answer: In React, event names are camelCase (e.g., onClick instead of onclick), and you
pass a function reference rather than a string. React also uses a SyntheticEvent
wrapper for cross-browser compatibility.
13. What are synthetic events in React?
Answer: SyntheticEvent is a wrapper around the browser’s native event. It ensures that
events have consistent properties across different browsers.
14. What are inline conditional expressions?
Answer: They allow you to conditionally render elements directly within JSX using
logical (&&) or ternary (? :) operators.
15. What is the 'key' prop and what is its benefit when used in arrays of elements?
Answer: The 'key' prop helps React identify which items have changed, are added, or
are removed. It improves rendering performance and helps avoid rendering bugs.
16. What is the Virtual DOM?
Answer: The Virtual DOM is a lightweight JavaScript object that represents the real
DOM. React uses it to optimize rendering by diffing and batching updates.
17. How does the Virtual DOM work?
Answer: React creates a virtual copy of the real DOM. When the state changes, React
compares the new Virtual DOM with the old one (diffing), calculates the most efficient
way to update the real DOM, and applies those changes.
18. What is the difference between Shadow DOM and Virtual DOM?
Answer: Shadow DOM is a browser technology used for encapsulating styles and
markup in web components. Virtual DOM is a concept used by React for efficient
rendering.
19. What is React Fiber?
Answer: React Fiber is the new reconciliation engine in React 16+. It enables features
like concurrency, prioritization, and pause/resume rendering.
20. What is the main goal of React Fiber?
Answer: To enable incremental rendering, improving responsiveness by splitting
rendering work into chunks that can be paused and resumed.