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 4101–4125 of 4608

Career & HR topics

By tech stack

Popular tracks

Junior PDF
What is the difference between Link and NavLink?

Short answer: Feature Link NavLink Purpose Navigate between pages Navigation with active styling Active style No built-in active style Automatically adds an active class when the route is active Use case Basic navigation…

React Read answer
Junior PDF
What is the difference between Link and NavLink?

Short answer: ctive style No built-in active style utomatically adds an active class when the route is ctive Use case Basic navigation For creating navigation menus with active links (e.g., highlighting the active link)…

React Read answer
Mid PDF
How do you implement protected routes?

Short answer: Protected routes are used to restrict access to certain routes based on some condition (e.g., user authentication). You can create a wrapper component that checks the condition and either redirects or rende…

React Read answer
Mid PDF
How do you implement protected routes?

Short answer: And either redirects or renders the requested route. import { Redirect, Route } from 'react-router-dom'; function ProtectedRoute({ component: Component, ...rest }) { const isAuthenticated = false; // Replac…

React Read answer
Mid PDF
How do you programmatically navigate in React Router?

Short answer: You can navigate programmatically using the useHistory hook (React Router v5) or useNavigate hook (React Router v6). For React Router v5 (useHistory): import { useHistory } from 'react-router-dom'; function…

React Read answer
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
Junior PDF
What is code splitting and how do you implement it?

Short answer: Code splitting is the practice of breaking up the bundle into smaller chunks so that only the required code is loaded when needed, improving initial load performance. How to Implement: Real-world example (S…

React Read answer
Junior PDF
What is lazy loading in React?

Short answer: Lazy loading is a design pattern where resources (like components) are loaded only when they are needed (e.g., when they enter the viewport or the user navigates to the route). In React, lazy loading is typ…

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
Junior PDF
What is Jest and how is it used with React?

Short answer: Jest is a JavaScript testing framework created by Facebook, commonly used for testing React applications. It comes with: Test runner: Executes test files. Assertions: Provides functions like expect() for as…

React Read answer
Junior PDF
What is React Testing Library and how does it differ from Enzyme?

Short answer: React Testing Library (RTL) and Enzyme are two popular testing utilities for React. Explain a bit more Feature React Testing Library Enzyme Philosophy Tests behavior from the user's perspective Tests compon…

React Read answer
Junior PDF
What is React Testing Library and how does it differ from Enzyme?

Short answer: ccessibility Shallow rendering, component state, and props Testing Approach Encourages testing DOM behavior and accessibility Encourages testing component internals and methods Integration with React Built…

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
Junior PDF
What is snapshot testing?

Short answer: Snapshot testing is a way of testing a component’s rendered output by saving it to a snapshot file and comparing it with future renders. This helps detect any unintended changes in the UI. How to write snap…

React Read answer

React.js React.js Tutorial · React

Short answer: Feature Link NavLink Purpose Navigate between pages Navigation with active styling Active style No built-in active style Automatically adds an active class when the route is active Use case Basic navigation For creating navigation menus with active links (e.g., highlighting the active link) Example of NavLink: import { NavLink } from 'react-router-dom'; function Navbar() { return ( <nav> <NavLink to="/"…

Explain a bit more

activeClassName="active">Home</NavLink> <NavLink to="/about" activeClassName="active">About</NavLink> </nav> ); }

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: ctive style No built-in active style utomatically adds an active class when the route is ctive Use case Basic navigation For creating navigation menus with active links (e.g., highlighting the active link) Example of NavLink: import { NavLink } from 'react-router-dom'; function Navbar() { return ( <nav> <NavLink to="/"… ……… activeClassName="active">Home</NavLink> <NavLink to="/about"…

Explain a bit more

activeClassName="active">About</NavLink> </nav> ); } ctive style No built-in active style utomatically adds an active class when the route is ctive Use case Basic navigation For creating navigation menus with active links (e.g., highlighting the active link) Example of NavLink: import { NavLink } from 'react-router-dom'; function Navbar() { return ( <nav> <NavLink to="/" activeClassName="active">Home</NavLink> <NavLink to="/about" activeClassName="active">About</NavLink> </nav> ); } ctive style No built-in active style utomatically adds an active class when the route is ctive Use case Basic navigation For creating navigation menus…

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: Protected routes are used to restrict access to certain routes based on some condition (e.g., user authentication). You can create a wrapper component that checks the condition and either redirects or renders the requested route.

Example code

import { Redirect, Route } from 'react-router-dom'; function ProtectedRoute({ component: Component, ...rest }) { const isAuthenticated = false; // Replace with your auth logic return ( <Route {...rest} render={(props) => isAuthenticated ? ( <Component {...props} /> ) : ( <Redirect to="/login" /> } /> ); } function App() { return ( <Router> <Switch> <Route path="/login" component={Login} /> <ProtectedRoute path="/dashboard" component={Dashboard} /> </Switch> </Router> ); } In this example, if the user is not authenticated, they will be redirected to the login page when trying to access the /dashboard route.

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 either redirects or renders the requested route. import { Redirect, Route } from 'react-router-dom'; function ProtectedRoute({ component: Component, ...rest }) { const isAuthenticated = false; // Replace with your auth logic return ( <Route {...rest} render={(props) => isAuthenticated ? And either redirects or renders the requested route.

Example code

import { Redirect, Route } from 'react-router-dom'; function ProtectedRoute({ component: Component, ...rest }) { const isAuthenticated = false; // Replace with your auth logic return ( <Route {...rest} render={(props) => isAuthenticated ? nd either redirects or renders the requested route. Example: import { Redirect, Route } from 'react-router-dom'; function ProtectedRoute({ component: Component, ...rest }) { const isAuthenticated = false; // Replace with your auth logic return ( <Route {...rest} render={(props) => isAuthenticated ? ( <Component {...props} /> ) : ( <Redirect to="/login" /> } /> ); } function App() { return ( <Router> <Switch> <Route path="/login" component={Login} /> <ProtectedRoute path="/dashboard" component={Dashboard} /> </Switch> </Router> ); } In this example, if the user is not authenticated, they will be redirected to the login page when trying to access the /dashboard route. nd either redirects or renders the requested route. Example: import { Redirect, Route } from 'react-router-dom'; function ProtectedRoute({ component: Component, ...rest }) { const isAuthenticated = false; // Replace with your auth logic return ( <Route {...rest} render={(props) => isAuthenticated ? ( <Component {...props} /> ) : ( <Redirect to="/login" /> } /> ); } function App() { return ( <Router> <Switch> <Route path="/login" component={Login} /> <ProtectedRoute path="/dashboard" component={Dashboard} /> </Switch> </Router> ); } In this example, if the user is not authenticated, they will be redirected to the login page when trying to access the /dashboard route.

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: You can navigate programmatically using the useHistory hook (React Router v5) or useNavigate hook (React Router v6). For React Router v5 (useHistory): import { useHistory } from 'react-router-dom'; function MyComponent() { const history = useHistory(); const goToHome = () => { history.push('/'); }; return <button onClick={goToHome}>Go to Home</button>;

Example code

}
For React Router v6 (useNavigate): import { useNavigate } from 'react-router-dom'; function MyComponent() { const navigate = useNavigate(); const goToHome = () => { navigate('/'); }; return <button onClick={goToHome}>Go to Home</button>;
} React Performance Optimization

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: 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: Code splitting is the practice of breaking up the bundle into smaller chunks so that only the required code is loaded when needed, improving initial load performance. How to Implement:

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: Lazy loading is a design pattern where resources (like components) are loaded only when they are needed (e.g., when they enter the viewport or the user navigates to the route). In React, lazy loading is typically implemented using React.lazy and Suspense.

Example code

import { Suspense } from 'react'; const HeavyComponent = React.lazy(() => import('./HeavyComponent')); function App() { return ( <Suspense fallback={<div>Loading...</div>}> <HeavyComponent /> </Suspense> ); } This ensures that the heavy component is only loaded when the app actually needs it.

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: Jest is a JavaScript testing framework created by Facebook, commonly used for testing React applications. It comes with: Test runner: Executes test files. Assertions: Provides functions like expect() for asserting conditions. Mocks: Mocking capabilities for API calls or functions. Snapshots: Captures UI output at a given time. How to use Jest with React: Install Jest: npm install --save-dev jest

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: React Testing Library (RTL) and Enzyme are two popular testing utilities for React.

Explain a bit more

Feature React Testing Library Enzyme Philosophy Tests behavior from the user's perspective Tests component internals and implementation Test Focus Interaction, rendering, and accessibility Shallow rendering, component state, and props Testing Approach Encourages testing DOM behavior and accessibility Encourages testing component internals and methods Integration with React Built with React’s rendering behavior in mind Requires enzyme adapter for different React versions Recommendation More modern, encourages better testing practices Still used, but React Testing Library is more popular Key difference: React Testing Library focuses on testing the output of your components (UI behavior), similar to how a user interacts with the app. Enzyme focuses more on testing the internal implementation (component state, methods).

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: ccessibility Shallow rendering, component state, and props Testing Approach Encourages testing DOM behavior and accessibility Encourages testing component internals and methods Integration with React Built with React’s rendering behavior in mind Requires enzyme adapter for different React versions Recommendation More modern,… encourages better testing…… practices Still used, but React Testing Library is more popular…

Explain a bit more

Key difference: React Testing Library focuses on testing the output of your components (UI behavior), similar to how a user interacts with the app. Enzyme focuses more on testing the internal implementation (component state, methods).

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: Snapshot testing is a way of testing a component’s rendered output by saving it to a snapshot file and comparing it with future renders. This helps detect any unintended changes in the UI. How to write snapshot tests: Run Jest with snapshot testing: npm test -- --updateSnapshot

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