frontend-interview-questions

1. What techniques can you use to optimize the performance of a React application?


2. Explain the purpose of React.memo and when you would use it.

React.memo is a HOC that prevents unnecessary re-renders of a component if its props haven’t changed.

Use case: Functional components that are pure and receive the same props repeatedly.

It’s especially useful in list rendering or nested components where the parent re-renders frequently.


3. How do useCallback and useMemo hooks work, and how do they help with performance?

Why it matters: Avoids unnecessary recreation of functions or values, which helps prevent re-renders or re-calculations, especially when passing props to child components or dependencies to useEffect.


4. What is code splitting in React, and how can you implement it using lazy loading?

Code splitting breaks your app into smaller chunks that load on demand , improving initial load time.

This loads Profile only when needed. Use React.lazy with Suspense for route-based or component-level code splitting.


5. How would you debug and resolve a performance issue caused by excessive re-rendering in a React app?

Steps:

  1. Enable React DevTools → highlight re-renders.
  2. Use the Profiler tab to find frequently updated components.
  3. Check props/state dependencies and memoize components (React.memo) or callbacks (useCallback).
  4. Ensure useEffect and context consumers aren’t triggering unnecessary updates.
  5. Apply shouldComponentUpdate logic or useMemo to prevent re-renders.


6. How do you measure and improve Core Web Vitals (LCP, FID, CLS) in a React.js application?


7. Describe a time when you identified and fixed a performance bottleneck in a frontend application.

In a data-heavy dashboard, charts re-rendered on every state change due to new props passed down each time. I:

This reduced render time from ~800ms to ~100ms and eliminated UI lag.


8. How would you optimize a React app that suffers from slow initial load times due to a large bundle size?


9. How do you profile a React application to identify unnecessary renders or memory leaks?


10. You notice a memory leak in a React application. How would you identify and fix it?

Identification:

Fixes: