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 2901–2925 of 3281

Career & HR topics

By tech stack

Popular tracks

Mid PDF
Mock axios: import axios from 'axios'; jest.mock('axios');?

Short answer: xios.get.mockResolvedValue({ data: 'mock data' }); xios.get.mockResolvedValue({ data: 'mock data' }); xios.get.mockResolvedValue({ data: 'mock data' }); xios.get.mockResolvedValue({ data: 'mock data' }); Re…

React Read answer
Mid PDF
Choose a Testing Library: Use libraries like Jest (test runner) and React Testing?

Short answer: Library (for testing React components). 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
React Developer Tools:?

Short answer: Use the Profiler tab to measure the render times and identify slow components. Check for unnecessary re-renders and optimize with React.memo or shouldComponentUpdate. Real-world example (ShopNest) ShopNest’…

React Read answer
Mid PDF
Only call hooks at the top level?

Short answer: (Don’t call hooks inside loops, conditions, or nested functions.) Real-world example (ShopNest) ShopNest’s cart icon uses useState for count and useEffect to load the cart once on mount. Say this in the int…

React Read answer
Mid PDF
Write a snapshot test using Jest:?

Short answer: import { render } from '@testing-library/react'; import MyComponent from './MyComponent'; test('matches snapshot', () => { const { asFragment } = render(<MyComponent />); expect(asFragment()).toMat…

React Read answer
Mid PDF
Example of mocking fetch in a test:?

Short answer: import { render, screen, waitFor } from '@testing-library/react'; import MyComponent from './MyComponent'; test('fetches and displays data', async () => { global.fetch = jest.fn(() => Promise.resolve(…

React Read answer
Mid PDF
Console Logs and performance.now():?

Short answer: Log the time it takes for certain parts of your app to render and pinpoint slow areas. Real-world example (ShopNest) Heavy product grids memoize row components so typing in the search box does not re-render…

React Read answer
Mid PDF
Babel: A JavaScript compiler that enables the use of modern JavaScript features?

Short answer: (ES6+) and JSX syntax in React. 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 intervi…

React Read answer
Mid PDF
This HTML is sent to the client, where React "hydrates" it, attaching event listeners?

Short answer: const server = express(); server.get('*', (req, res) => { const content = ReactDOMServer.renderToString(<App />); res.send(` <html> <head><title>SSR Example</title></head…

React Read answer
Mid PDF
Use a fallback UI to handle errors gracefully.?

Short answer: Example: class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error) { return { hasError: true }; // Update st…

React Read answer
Mid PDF
Example of mocking fetch in a test: import { render, screen, waitFor } from '@testing-library/react'; import MyComponent from './MyComponent'; test('fetches and displays data', async () => { global.fetch = jest.fn(() => Promise.resolve({ json: () => Promise.resolve({ message: 'Data loaded' }), }) ); render(<MyComponent />);

Short answer: wait waitFor(() =&gt; screen.getByText('Data loaded')); expect(screen.getByText('Data loaded')).toBeInTheDocument(); }); Here, we mock the fetch function to return mock data, then test whether it appears in…

React Read answer
Mid PDF
Key Prop: Always provide a unique key to each list item to help React efficiently?

Short answer: update only the items that have changed. update only the items that have changed. Real-world example (ShopNest) When rendering cart lines, use a stable key={item.id} —not the array index—so React updates th…

React Read answer
Mid PDF
Use Suspense to handle the loading state while the component is loading.?

Short answer: import React, { Suspense } from 'react'; const LazyComponent = React.lazy(() =&gt; import('./LazyComponent')); function App() { return ( &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt; &lt;Laz…

React Read answer
Mid PDF
Wrap your app with BrowserRouter (or HashRouter):?

Short answer: import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; function App() { return ( &lt;Router&gt; &lt;Switch&gt; &lt;Route exact path=&quot;/&quot; component={Home} /&gt; &lt;Route path=&q…

React Read answer
Mid PDF
Reducer: A pure function that returns the next state.?

Short answer: function counterReducer(state = 0, action) { switch (action.type) { case 'INCREMENT': return state + 1; default: return state; } } Example code function counterReducer(state = 0, action) { switch (action.ty…

React Read answer
Mid PDF
Only call hooks from React functions?

Short answer: (functional components or custom hooks) React enforces these rules with a linter: eslint-plugin-react-hooks. Real-world example (ShopNest) ShopNest’s cart icon uses useState for count and useEffect to load…

React Read answer
Mid PDF
What are the main features of React?

Short answer: JSX – JavaScript + XML Components – Reusable and composable Virtual DOM – Efficient DOM updates Unidirectional data flow – One-way data binding Lifecycle methods (in class components) Hooks (in functional c…

React Read answer
Mid PDF
State updates with closures: If using state in a function inside useEffect, make?

Short answer: sure to account for the most recent state. Real-world example (ShopNest) ShopNest’s cart icon uses useState for count and useEffect to load the cart once on mount. Say this in the interview Define — one cle…

React Read answer
Mid PDF
JSS: A framework-agnostic CSS-in-JS solution that works well with React.?

Short answer: These libraries help solve problems like global namespace conflicts and style collisions in large React applications, allowing for scoped, dynamic styles. Real-world example (ShopNest) ShopNest’s storefront…

React Read answer
Mid PDF
CSS Modules:?

Short answer: Scoped CSS that helps avoid name collisions. import styles from './App.module.css'; function App() { return &lt;div className={styles.container}&gt;Hello, world!&lt;/div&gt;; Real-world example (ShopNest) S…

React Read answer
Mid PDF
ESLint: A static code analysis tool that identifies problematic patterns in JavaScript,?

Short answer: making sure your code follows a consistent style. Real-world example (ShopNest) ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state. Say t…

React Read answer
Mid PDF
Assertions: Use expect() to assert the expected behavior.?

Short answer: Example: import { render, screen, fireEvent } from '@testing-library/react'; import MyComponent from './MyComponent'; test('renders the component and interacts', () =&gt; { render(&lt;MyComponent /&gt;); co…

React Read answer
Mid PDF
React's useEffect Dependency Analysis:?

Short answer: If using hooks, make sure you are providing the correct dependencies to useEffect and useMemo, and avoid unnecessary recalculations. Real-world example (ShopNest) ShopNest’s cart icon uses useState for coun…

React Read answer
Mid PDF
Virtualization: Use libraries like react-window or react-virtualized to only render?

Short answer: the items that are visible in the viewport. Example of list optimization with key: const List = ({ items }) =&gt; { return ( &lt;ul&gt; {items.map(item =&gt; ( &lt;li key={item.id}&gt;{item.name}&lt;/li&gt;…

React Read answer
Mid PDF
Store: Holds the state and dispatches actions.?

Short answer: import { createStore } from 'redux'; const store = createStore(counterReducer); Example code import { createStore } from 'redux'; const store = createStore(counterReducer); Real-world example (ShopNest) Pro…

React Read answer

React.js React.js Tutorial · React

Short answer: xios.get.mockResolvedValue({ data: 'mock data' }); xios.get.mockResolvedValue({ data: 'mock data' }); xios.get.mockResolvedValue({ data: 'mock data' }); xios.get.mockResolvedValue({ 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: Library (for testing React components).

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: Use the Profiler tab to measure the render times and identify slow components. Check for unnecessary re-renders and optimize with React.memo or shouldComponentUpdate.

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: (Don’t call hooks inside loops, conditions, or nested functions.)

Real-world example (ShopNest)

ShopNest’s cart icon uses useState for count and useEffect to load the cart once on mount.

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: import { render } from '@testing-library/react'; import MyComponent from './MyComponent'; test('matches snapshot', () => { const { asFragment } = render(<MyComponent />); expect(asFragment()).toMatchSnapshot(); }); asFragment() captures the rendered output as a DOM snapshot.

Explain a bit more

toMatchSnapshot() compares the output to a previously saved snapshot. The first time the test is run, it saves the output to a snapshot file. On subsequent runs, it compares the output to the saved snapshot. If there are any changes, the test will fail. Advanced React Concepts

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: import { render, screen, waitFor } from '@testing-library/react'; import MyComponent from './MyComponent'; test('fetches and displays data', async () => { global.fetch = jest.fn(() => Promise.resolve({ json: () => Promise.resolve({ message: 'Data loaded' }), }) ); render(<MyComponent />); await waitFor(() => screen.getByText('Data loaded')); expect(screen.getByText('Data loaded')).toBeInTheDocument(); }); Here, we…

Explain a bit more

mock the fetch function to return mock data, then test whether it appears in the component.

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: Log the time it takes for certain parts of your app to render and pinpoint slow areas.

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: (ES6+) and JSX syntax in React.

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: const server = express(); server.get('*', (req, res) => { const content = ReactDOMServer.renderToString(<App />); res.send(` <html> <head><title>SSR Example</title></head> <body> <div id="root">${content}</div> </body> </html> `); }); server.listen(3000, () => console.log('Server running on In this setup, React renders the app to HTML on the server, then the client "hydrates" it for interactivity.

Example code

and making it interactive. Example with express and React: const express = require('express');
const React = require('react');
const ReactDOMServer = require('react-dom/server');
const App = require('./App');

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: Example: class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error) { return { hasError: true }; // Update state to trigger a fallback UI } componentDidCatch(error, info) { console.error("Error caught by Error Boundary:", error, info); } render() { if (this.state.hasError) { return <h1>Something went wrong!</h1>; }…

Explain a bit more

return this.props.children; } } export default ErrorBoundary; You can wrap parts of your app in this ErrorBoundary to gracefully handle errors.

Example code

Example: class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false };
} static getDerivedStateFromError(error) { return { hasError: true }; // Update state to trigger a fallback UI } componentDidCatch(error, info) { console.error("Error caught by Error Boundary:", error, info); } render() { if (this.state.hasError) {
return <h1>Something went wrong!</h1>;
}
return this.props.children;
}
} export default ErrorBoundary; You can wrap parts of your app in this ErrorBoundary to gracefully handle errors.

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('Data loaded')); expect(screen.getByText('Data loaded')).toBeInTheDocument(); }); Here, we mock the fetch function to return mock data, then test whether it appears in the component.

Explain a bit more

wait waitFor(() => screen.getByText('Data loaded')); expect(screen.getByText('Data loaded')).toBeInTheDocument(); }); Here, we mock the fetch function to return mock data, then test whether it appears in the component. wait waitFor(() => screen.getByText('Data loaded')); expect(screen.getByText('Data loaded')).toBeInTheDocument(); }); Here, we mock the fetch function to return mock data, then test whether it appears in the component.

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: update only the items that have changed. update only the items that have changed.

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: import React, { Suspense } from 'react'; const LazyComponent = React.lazy(() => import('./LazyComponent')); function App() { return ( <Suspense fallback={<div>Loading...</div>}> <LazyComponent /> </Suspense> ); } React.lazy enables dynamic imports for code splitting. Suspense lets you specify a loading state while waiting for the component to load.

Real-world example (ShopNest)

ProductCard receives price via props. The parent Catalog owns selected filters in state and passes them down.

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: import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; function App() { return ( <Router> <Switch> <Route exact path="/" component={Home} /> <Route path="/about" component={About} /> </Switch> </Router> ); }

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: function counterReducer(state = 0, action) { switch (action.type) { case 'INCREMENT': return state + 1; default: return state; } }

Example code

function counterReducer(state = 0, action) { switch (action.type) { case 'INCREMENT': return state + 1; default: return state;
}
}

Real-world example (ShopNest)

ProductCard receives price via props. The parent Catalog owns selected filters in state and passes them down.

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: (functional components or custom hooks) React enforces these rules with a linter: eslint-plugin-react-hooks.

Real-world example (ShopNest)

ShopNest’s cart icon uses useState for count and useEffect to load the cart once on mount.

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: JSX – JavaScript + XML Components – Reusable and composable Virtual DOM – Efficient DOM updates Unidirectional data flow – One-way data binding Lifecycle methods (in class components) Hooks (in functional components)

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: sure to account for the most recent state.

Real-world example (ShopNest)

ShopNest’s cart icon uses useState for count and useEffect to load the cart once on mount.

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: These libraries help solve problems like global namespace conflicts and style collisions in large React applications, allowing for scoped, dynamic styles.

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: Scoped CSS that helps avoid name collisions. import styles from './App.module.css'; function App() { return <div className={styles.container}>Hello, world!</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: making sure your code follows a consistent style.

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: Example: import { render, screen, fireEvent } from '@testing-library/react'; import MyComponent from './MyComponent'; test('renders the component and interacts', () => { render(<MyComponent />); const button = screen.getByText('Click me'); fireEvent.click(button); expect(screen.getByText('Clicked!')).toBeInTheDocument(); });

Example code

import { render, screen, fireEvent } from '@testing-library/react'; import MyComponent from './MyComponent'; test('renders the component and interacts', () => { render(<MyComponent />); const button = screen.getByText('Click me'); fireEvent.click(button); expect(screen.getByText('Clicked!')).toBeInTheDocument(); });

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: If using hooks, make sure you are providing the correct dependencies to useEffect and useMemo, and avoid unnecessary recalculations.

Real-world example (ShopNest)

ShopNest’s cart icon uses useState for count and useEffect to load the cart once on mount.

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: the items that are visible in the viewport. Example of list optimization with key: const List = ({ items }) => { return ( <ul> {items.map(item => ( <li key={item.id}>{item.name}</li> ))} </ul> ); };

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: import { createStore } from 'redux'; const store = createStore(counterReducer);

Example code

import { createStore } from 'redux'; const store = createStore(counterReducer);

Real-world example (ShopNest)

ProductCard receives price via props. The parent Catalog owns selected filters in state and passes them down.

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