← All videos

Engineering video

9:14 · 17 April 2024

React.js Interview Questions

Chapters 6 sections

  1. 0:00Introduction and Rules of Hooks
  2. 0:43React Lazy and Suspense
  3. 2:14List Keys
  4. 3:00Use Memo

Key concepts in this video:

1. Two Rules of Hooks

Always use hooks at the top of a component and avoid loops or conditions. Only call hooks inside React components or custom hooks.

Watch section from 0:13 →

2. React Lazy and Suspense

React lazy uses Webpack dynamic imports to separate code into unique bundles for lazy loading, while suspense displays a fallback while loading.

Watch section from 0:43 →

3. List Keys in React

Using a unique key attribute helps React identify list items and avoid re-rendering elements that are still present, improving performance.

Watch section from 2:14 →

4. Use Memo Hook

Use memo memorizes expensive computed values across renders, recomputing them only if the dependency array changes.

Watch section from 3:00 →

5. React Context and Re-renders

Context allows passing state without prop drilling, but unrelated state in a single context causes unnecessary re-renders across connected components.

Watch section from 4:00 →

6. Class Components vs Functional Components

Class components allow direct access to lifecycle methods, enabling features like error boundaries that are not directly available in functional components.

Watch section from 7:12 →

Transcript

Today we are going to go to some senior React interview questions. These questions cover many topics about React, about depth. Feel free to showcase your uh software engineer skills. First question, senior level question. What are the two rules of hooks in React? Okay, so the two rules of hooks in React are number one, you should always use hooks at the top of your component and avoid using them inside while or for loops, that will probably um trigger very um unexpected behaviors.