Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: import axios from 'axios'; jest.mock('axios'); axios.get.mockResolvedValue({ data: 'mock data' }); Example code import axios from 'axios'; jest.mock('axios'); axios.get.mockResolvedValue({ data: 'mock data'…
Short answer: React is a JavaScript library for building user interfaces, mainly for single-page applications. It helps developers create reusable UI components, manage state efficiently, and update the UI in a performan…
Short answer: on the server. This allows search engines to crawl the content. Real-world example (ShopNest) ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local U…
Short answer: dependencies can lead to bugs or infinite loops. 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 — o…
Short answer: styled based on props or state. 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…
Short answer: You can import regular CSS files directly into your components. import './App.css'; // Regular CSS file Real-world example (ShopNest) ShopNest’s storefront is React: components for ProductCard, CartDrawer,…
Short answer: assets. It’s highly configurable and can be used for React apps, though tools like CRA automate this. Real-world example (ShopNest) ShopNest’s storefront is React: components for ProductCard, CartDrawer, an…
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…
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…
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’…
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…
Short answer: React is a JavaScript library for building user interfaces, mainly for single-page applications. It helps developers create reusable UI components, manage state efficiently, and update the UI in a performan…
Short answer: import { render } from '@testing-library/react'; import MyComponent from './MyComponent'; test('matches snapshot', () => { const { asFragment } = render(<MyComponent />); expect(asFragment()).toMat…
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(…
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…
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…
Short answer: const server = express(); server.get('*', (req, res) => { const content = ReactDOMServer.renderToString(<App />); res.send(` <html> <head><title>SSR Example</title></head…
Short answer: Example: class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error) { return { hasError: true }; // Update st…
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…
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…
Short answer: import React, { Suspense } from 'react'; const LazyComponent = React.lazy(() => import('./LazyComponent')); function App() { return ( <Suspense fallback={<div>Loading...</div>}> <Laz…
Short answer: import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; function App() { return ( <Router> <Switch> <Route exact path="/" component={Home} /> <Route path=&q…
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…
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…
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.js React.js Tutorial · React
Short answer: import axios from 'axios'; jest.mock('axios'); axios.get.mockResolvedValue({ data: 'mock data' });
import axios from 'axios'; jest.mock('axios'); axios.get.mockResolvedValue({ data: 'mock data' });
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
React.js React.js Tutorial · React
Short answer: React is a JavaScript library for building user interfaces, mainly for single-page applications. It helps developers create reusable UI components, manage state efficiently, and update the UI in a performant way. ✅ Why use React? Easy to break UIs into components Efficient updates with Virtual DOM Rich ecosystem (React Router, Redux, etc.) Backed by Facebook and a large community
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
React.js React.js Tutorial · React
Short answer: on the server. This allows search engines to crawl the content.
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
React.js React.js Tutorial · React
Short answer: dependencies can lead to bugs or infinite loops.
ShopNest’s cart icon uses useState for count and useEffect to load the cart once on mount.
React.js React.js Tutorial · React
Short answer: styled based on props or state.
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
React.js React.js Tutorial · React
Short answer: You can import regular CSS files directly into your components. import './App.css'; // Regular CSS file
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
React.js React.js Tutorial · React
Short answer: assets. It’s highly configurable and can be used for React apps, though tools like CRA automate this.
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
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' });
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
React.js React.js Tutorial · React
Short answer: Library (for testing React components).
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
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.
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
React.js React.js Tutorial · React
Short answer: (Don’t call hooks inside loops, conditions, or nested functions.)
ShopNest’s cart icon uses useState for count and useEffect to load the cart once on mount.
React.js React.js Tutorial · React
Short answer: React is a JavaScript library for building user interfaces, mainly for single-page applications. It helps developers create reusable UI components, manage state efficiently, and update the UI in a performant way. ✅ Why use React? Easy to break UIs into components Efficient updates with Virtual DOM Rich ecosystem (React Router, Redux, etc.) Backed by Facebook and a large community
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
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.
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
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
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…
mock the fetch function to return mock data, then test whether it appears in the component.
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
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.
Heavy product grids memoize row components so typing in the search box does not re-render every image card unnecessarily.
React.js React.js Tutorial · React
Short answer: (ES6+) and JSX syntax in React.
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
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.
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');
When rendering cart lines, use a stable key={item.id}—not the array index—so React updates the right row after delete.
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>; }…
return this.props.children; } } export default ErrorBoundary; You can wrap parts of your app in this ErrorBoundary to gracefully handle errors.
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.
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
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.
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.
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
React.js React.js Tutorial · React
Short answer: update only the items that have changed. update only the items that have changed.
When rendering cart lines, use a stable key={item.id}—not the array index—so React updates the right row after delete.
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.
ProductCard receives price via props. The parent Catalog owns selected filters in state and passes them down.
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> ); }
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
React.js React.js Tutorial · React
Short answer: function counterReducer(state = 0, action) { switch (action.type) { case 'INCREMENT': return state + 1; default: return state; } }
function counterReducer(state = 0, action) { switch (action.type) { case 'INCREMENT': return state + 1; default: return state;
}
}
ProductCard receives price via props. The parent Catalog owns selected filters in state and passes them down.
React.js React.js Tutorial · React
Short answer: (functional components or custom hooks) React enforces these rules with a linter: eslint-plugin-react-hooks.
ShopNest’s cart icon uses useState for count and useEffect to load the cart once on mount.
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)
ShopNest’s storefront is React: components for ProductCard, CartDrawer, and CheckoutForm, with hooks for local UI state.
Install Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.