Interview Q&A

Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.

4608 total questions 4508 technical 100 career & HR 4272 from PDF library

Showing 76–100 of 112

Popular tracks

Mid PDF
What are common causes of performance issues in React apps?

Short answer: Common causes of performance issues include: Real-world example (ShopNest) Heavy product grids memoize row components so typing in the search box does not re-render every image card unnecessarily. Say this…

React Read answer
Mid PDF
How does React.memo improve performance?

Short answer: React.memo is a higher-order component that memoizes functional components. It only re-renders the component if its props have changed. Before: Every re-render, even if props haven’t changed. After: Prevent…

React Read answer
Mid PDF
How do useMemo and useCallback help with performance?

Short answer: useMemo: useMemo is a hook that memoizes the result of an expensive function call and only recomputes the value when one of the dependencies changes. Use case: Expensive calculations or operations that don’…

React Read answer
Mid PDF
How does React’s shouldComponentUpdate method work?

Short answer: shouldComponentUpdate is a lifecycle method in class components that determines whether a component should re-render. Explain a bit more By default, a component re-renders when state or props change, but sh…

React Read answer
Mid PDF
How can you optimize rendering lists in React?

Short answer: Rendering large lists can cause performance issues if each item re-renders unnecessarily. Here are some strategies: Real-world example (ShopNest) When rendering cart lines, use a stable key={item.id} —not t…

React Read answer
Mid PDF
What are pure components?

Short answer: A Pure Component is a React class component that automatically implements shouldComponentUpdate with a shallow prop and state comparison. Benefit: It prevents unnecessary re-renders by performing a shallow…

React Read answer
Mid PDF
How does virtualization work in React lists?

Short answer: Virtualization is a technique where only the items that are visible in the viewport are rendered, while the others are not rendered until they come into view. Explain a bit more This significantly reduces t…

React Read answer
Mid PDF
How do you debug performance issues in React apps?

Short answer: Debugging performance issues can be done using several tools and strategies: Real-world example (ShopNest) Heavy product grids memoize row components so typing in the search box does not re-render every ima…

React Read answer
Mid PDF
How do you test React components?

Short answer: You test React components by writing unit tests that simulate rendering, interaction, and lifecycle behavior. Key Steps: Real-world example (ShopNest) ShopNest’s storefront is React: components for ProductC…

React Read answer
Mid PDF
How do you write a unit test for a React component?

Short answer: A unit test checks a small unit of functionality, such as a React component. Here’s how you can write a unit test: Real-world example (ShopNest) ShopNest’s storefront is React: components for ProductCard, C…

React Read answer
Mid PDF
How do you test component interactions and events?

Short answer: To test component interactions like button clicks, form submissions, or other events, you can use fireEvent or user-event (for more realistic user interactions). Explain a bit more Example using fireEvent:…

React Read answer
Mid PDF
How do you mock API calls in tests?

Short answer: To mock API calls in tests, you can use jest.mock() to mock functions or API calls. Mocking fetch or axios: Mock fetch: global.fetch = jest.fn(() => Promise.resolve({ json: () => Promise.resolve({ dat…

React Read answer
Mid PDF
How do you test async behavior in React components?

Short answer: Testing async behavior often involves waiting for a component to update based on API calls or timeouts. Example code Use waitFor or findBy queries to wait for async changes. import { render, screen, waitFor…

React Read answer
Mid PDF
How do you test async behavior in React components?

Short answer: wait waitFor(() => screen.getByText('Loaded Data')); expect(screen.getByText('Loaded Data')).toBeInTheDocument(); }); In this case, waitFor() waits until the expected element appears in the DOM after an…

React Read answer
Mid PDF
What are Higher-Order Components (HOCs)?

Short answer: A Higher-Order Component (HOC) is a function that takes a component and returns a new component with additional props or behavior. Explain a bit more Purpose: HOCs are used for code reuse, logic abstraction…

React Read answer
Mid PDF
What are React Portals and when would you use them?

Short answer: A Portal provides a way to render children into a different part of the DOM outside of the parent component’s DOM hierarchy. Explain a bit more This is particularly useful for scenarios like modals, tooltip…

React Read answer
Mid PDF
How does an error boundary work in React?

Short answer: An Error Boundary is a React component that catches JavaScript errors in its child components, logs those errors, and displays a fallback UI. This prevents the entire app from crashing when an error occurs…

React Read answer
Mid PDF
What are controlled side effects?

Short answer: Controlled side effects refer to operations in React that happen as a result of state or props changes but are carefully managed, typically using React Hooks like useEffect. Explain a bit more Examples: Fet…

React Read answer
Mid PDF
How do you implement server-side rendering (SSR) with React?

Short answer: Server-Side Rendering (SSR) allows React components to be rendered on the server and the resulting HTML to be sent to the client. This improves the initial loading performance and helps with SEO. SSR Proces…

React Read answer
Mid PDF
How do you implement server-side rendering (SSR) with React?

Short answer: And helps with SEO. SSR Process: Real-world example (ShopNest) ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state. Say this in the interv…

React Read answer
Mid PDF
What are common build tools used with React?

Short answer: Some common build tools for React are: Real-world example (ShopNest) ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state. Say this in the…

React Read answer
Mid PDF
How do you handle CSS in React applications?

Short answer: There are several ways to handle CSS in React applications, and each comes with its own pros and cons. Real-world example (ShopNest) ShopNest’s storefront is React: components for ProductCard, CartDrawer, a…

React Read answer
Mid PDF
What are CSS-in-JS libraries?

Short answer: CSS-in-JS libraries allow you to write CSS styles directly inside JavaScript files, enabling better component encapsulation and dynamic styling. Popular libraries include: Real-world example (ShopNest) Shop…

React Read answer
Mid PDF
How do you do internationalization (i18n) in React?

Short answer: Internationalization (i18n) in React can be handled using libraries that help manage translations, time formats, and currency formatting. The most common libraries are: Real-world example (ShopNest) ShopNes…

React Read answer
Mid PDF
How do you handle authentication in React apps?

Short answer: Authentication in React apps is typically done using tokens (JWTs) and local storage to persist user sessions. Common Steps: Real-world example (ShopNest) ShopNest’s storefront is React: components for Prod…

React Read answer

React.js React.js Tutorial · React

Short answer: Common causes of performance issues include:

Real-world example (ShopNest)

Heavy product grids memoize row components so typing in the search box does not re-render every image card unnecessarily.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: React.memo is a higher-order component that memoizes functional components. It only re-renders the component if its props have changed. Before: Every re-render, even if props haven’t changed. After: Prevents unnecessary re-renders when props remain the same. const MyComponent = React.memo(function MyComponent({ name }) { return <div>{name}</div>; }); // MyComponent will only re-render if the `name` prop changes

Real-world example (ShopNest)

Heavy product grids memoize row components so typing in the search box does not re-render every image card unnecessarily.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: useMemo: useMemo is a hook that memoizes the result of an expensive function call and only recomputes the value when one of the dependencies changes. Use case: Expensive calculations or operations that don’t need to be recalculated on every render.

Example code

const expensiveValue = useMemo(() => computeExpensiveValue(a, b), [a, b]); // expensiveValue will only recompute when `a` or `b` changes useCallback: useCallback is used to memoize a function so it doesn’t get recreated on every render. Use case: Prevents function re-creation when passing functions down to child components (important when using React.memo or PureComponent). Example: const handleClick = useCallback(() => { // handle the click event }, [dependencies]); // Recreate the function only when dependencies change

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: shouldComponentUpdate is a lifecycle method in class components that determines whether a component should re-render.

Explain a bit more

By default, a component re-renders when state or props change, but shouldComponentUpdate allows you to optimize this behavior. Return false to prevent a re-render. Return true (or omit the method) to allow a re-render. Example: class MyComponent extends React.Component { shouldComponentUpdate(nextProps, nextState) { // Prevent re-render if props haven't changed return nextProps.name !== this.props.name;

Example code

} render() { return <div>{this.props.name}</div>;
}
}

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: Rendering large lists can cause performance issues if each item re-renders unnecessarily. Here are some strategies:

Real-world example (ShopNest)

When rendering cart lines, use a stable key={item.id}—not the array index—so React updates the right row after delete.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: A Pure Component is a React class component that automatically implements shouldComponentUpdate with a shallow prop and state comparison. Benefit: It prevents unnecessary re-renders by performing a shallow comparison of props and state. Example: class MyComponent extends React.PureComponent { render() { return <div>{this.props.name}</div>;

Example code

}
} Pure components are a good choice when you know that your component only depends on props and state and you want to avoid unnecessary updates.

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: Virtualization is a technique where only the items that are visible in the viewport are rendered, while the others are not rendered until they come into view.

Explain a bit more

This significantly reduces the number of DOM nodes and boosts performance when rendering large lists. Popular libraries for virtualization in React include: react-window react-virtualized Example with react-window: import { FixedSizeList as List } from 'react-window'; function MyList({ items }) { return ( <List height={400} itemCount={items.length} itemSize={35} width={300} {({ index, style }) => ( <div style={style}>{items[index]}</div> )} </List> ); } Only the visible items will be rendered, and as the user scrolls, new items will be loaded dynamically.

Real-world example (ShopNest)

When rendering cart lines, use a stable key={item.id}—not the array index—so React updates the right row after delete.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: Debugging performance issues can be done using several tools and strategies:

Real-world example (ShopNest)

Heavy product grids memoize row components so typing in the search box does not re-render every image card unnecessarily.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: You test React components by writing unit tests that simulate rendering, interaction, and lifecycle behavior. Key Steps:

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: A unit test checks a small unit of functionality, such as a React component. Here’s how you can write a unit test:

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: To test component interactions like button clicks, form submissions, or other events, you can use fireEvent or user-event (for more realistic user interactions).

Explain a bit more

Example using fireEvent: import { render, screen, fireEvent } from '@testing-library/react'; import MyComponent from './MyComponent'; test('button click changes text', () => { render(<MyComponent />); const button = screen.getByText('Click me'); fireEvent.click(button); expect(screen.getByText('You clicked!')).toBeInTheDocument(); }); Example using user-event (better for simulating real user interactions): npm install --save-dev @testing-library/user-event import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import MyComponent from './MyComponent'; test('button click changes text', () => { render(<MyComponent />); const button = screen.getByText('Click me'); userEvent.click(button); expect(screen.getByText('You clicked!')).toBeInTheDocument(); }); user-event is better because it simulates real user actions like clicks, typing, and…

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: To mock API calls in tests, you can use jest.mock() to mock functions or API calls. Mocking fetch or axios: Mock fetch: global.fetch = jest.fn(() => Promise.resolve({ json: () => Promise.resolve({ data: 'mock data' }), }) );

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: Testing async behavior often involves waiting for a component to update based on API calls or timeouts.

Example code

Use waitFor or findBy queries to wait for async changes. import { render, screen, waitFor } from '@testing-library/react'; import MyComponent from './MyComponent'; test('loads data asynchronously', async () => { render(<MyComponent />); // Wait for the element that should appear after the async call await waitFor(() => screen.getByText('Loaded Data')); expect(screen.getByText('Loaded Data')).toBeInTheDocument(); }); In this case, waitFor() waits until the expected element appears in the DOM after an async operation completes.

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: wait waitFor(() => screen.getByText('Loaded Data')); expect(screen.getByText('Loaded Data')).toBeInTheDocument(); }); In this case, waitFor() waits until the expected element appears in the DOM after an sync operation completes.

Explain a bit more

wait waitFor(() => screen.getByText('Loaded Data')); expect(screen.getByText('Loaded Data')).toBeInTheDocument(); }); In this case, waitFor() waits until the expected element appears in the DOM after an sync operation completes. wait waitFor(() => screen.getByText('Loaded Data')); expect(screen.getByText('Loaded Data')).toBeInTheDocument(); }); In this case, waitFor() waits until the expected element appears in the DOM after an sync operation completes.

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: A Higher-Order Component (HOC) is a function that takes a component and returns a new component with additional props or behavior.

Explain a bit more

Purpose: HOCs are used for code reuse, logic abstraction, and enhancing components with common functionality (e.g., authentication, data fetching, etc.). How it works: HOCs are like decorators that wrap a component and add extra logic before rendering the component. Example: function withLoading(Component) { return function WithLoading(props) {

Example code

if (props.isLoading) {
return <div>Loading...</div>;
}
return <Component {...props} />; }; }
const MyComponent = ({ data }) => <div>{data}</div>;
const MyComponentWithLoading = withLoading(MyComponent); In this example, withLoading is a higher-order component that adds loading state to MyComponent.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: A Portal provides a way to render children into a different part of the DOM outside of the parent component’s DOM hierarchy.

Explain a bit more

This is particularly useful for scenarios like modals, tooltips, or popups that need to visually break out of their parent component but still maintain their React component state. When to use: When you need to render content outside the DOM hierarchy of a parent, without losing the React component context (e.g., for modals, overlays, etc.).

Example code

import React from 'react'; import ReactDOM from 'react-dom'; function Modal() { return ReactDOM.createPortal( <div className="modal">This is a modal</div>, document.getElementById('modal-root') // Renders outside the normal DOM tree ); } export default Modal; In this case, the modal is rendered inside a specific part of the DOM (modal-root) even though it is a child of the Modal component.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: An Error Boundary is a React component that catches JavaScript errors in its child components, logs those errors, and displays a fallback UI. This prevents the entire app from crashing when an error occurs in a part of the component tree. Usage:

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: Controlled side effects refer to operations in React that happen as a result of state or props changes but are carefully managed, typically using React Hooks like useEffect.

Explain a bit more

Examples: Fetching data, subscribing to an event, manually updating the DOM, etc. Controlled: The side effect is triggered in response to specific state changes and cleaned up appropriately. Example of controlled side effect with useEffect: import React, { useState, useEffect } from 'react'; function MyComponent() { const [data, setData] = useState(null); useEffect(() => { const fetchData = async () => { const result = await fetch('/api/data'); const json = await result.json(); setData(json); }; fetchData(); }, []); // Only runs once when the component is mounted return <div>{data ? JSON.stringify(data) : 'Loading...'}</div>; } Here, useEffect handles the side effect of fetching data when the component mounts, and the state is updated with the fetched data.

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: Server-Side Rendering (SSR) allows React components to be rendered on the server and the resulting HTML to be sent to the client. This improves the initial loading performance and helps with SEO. SSR Process:

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: And helps with SEO. SSR Process:

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: Some common build tools for React are:

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: There are several ways to handle CSS in React applications, and each comes with its own pros and cons.

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: CSS-in-JS libraries allow you to write CSS styles directly inside JavaScript files, enabling better component encapsulation and dynamic styling. Popular libraries include:

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: Internationalization (i18n) in React can be handled using libraries that help manage translations, time formats, and currency formatting. The most common libraries are:

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

React.js React.js Tutorial · React

Short answer: Authentication in React apps is typically done using tokens (JWTs) and local storage to persist user sessions. Common Steps:

Real-world example (ShopNest)

ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details