arrow_back Back to Curriculum
react

React.js

Core concepts of the most popular UI library including Hooks, Virtual DOM, and component lifecycles.

Interview Questions

4 Total
Q1.

What is the Virtual DOM and how does React use it?

Medium

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.

Q2.

Explain the difference between useEffect and useLayoutEffect.

Hard

`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.

Q3.

How can you prevent a React component from unnecessary re-rendering?

Medium

You can use `React.memo` for component memoization, `useMemo` to cache expensive calculations, and `useCallback` to cache function references between renders.

Q4.

What is Prop Drilling and how do you solve it?

Easy

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.