React.js
Core concepts of the most popular UI library including Hooks, Virtual DOM, and component lifecycles.
Interview Questions
4 TotalWhat is the Virtual DOM and how does React use it?
The Virtual DOM is a lightweight in-memory representation of the real DOM. React compares the V-DOM with the real DOM (Diffing) and updates only the changed nodes (Reconciliation), making UI rendering much faster.
Explain the difference between useEffect and useLayoutEffect.
`useEffect` runs asynchronously AFTER the browser has painted the DOM. `useLayoutEffect` runs synchronously immediately after DOM mutations but BEFORE the browser paints, which prevents visual flickering when measuring DOM nodes.
How can you prevent a React component from unnecessary re-rendering?
You can use `React.memo` for component memoization, `useMemo` to cache expensive calculations, and `useCallback` to cache function references between renders.
What is Prop Drilling and how do you solve it?
Prop drilling is passing data down multiple nested components unnecessarily. We solve it using the Context API, or state management libraries like Redux or Zustand.