Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Feature Class Component Functional Component Syntax ES6 Class Function State this.state useState hook Lifecycle methods Yes Use useEffect, etc. Code size More verbose Cleaner and shorter ✅ Example: Class: class Welcome e…
React’s reconciliation algorithm compares the new Virtual DOM with the old one using a diffing algorithm. It: Identifies what changed (nodes, attributes, etc.) Applies minimum changes to the actual DOM Uses keys to track…
Answer: Utility-first CSS framework that uses predefined classes for layout and styling. Great for rapid development. What interviewers expect A clear definition tied to React in React.js projects Trade-offs (performance…
Answer: Props (short for "properties") are read-only data passed from a parent component to a child. ✅ Example: function Greeting(props) { return <h1>Hello, {props.name}!</h1>; } <Greet…
Answer: Functional component: Use setState from useState. Class component: Use this.setState(). ✅ Example: const [name, setName] = useState("John"); setName("Doe"); What interviewers expect A clear definition tied to Rea…
Answer: ✅ Using ternary: {isLoggedIn ? <Logout /> : <Login />} ✅ Using short-circuit: {isVisible && <Sidebar />} What interviewers expect A clear definition tied…
Answer: Fragments let you return multiple elements without adding an extra DOM node. ✅ Example: <> <h1>Title</h1> <p>Description</p> </>…
Answer: React uses camelCase syntax and passes functions directly. ✅ Example: <button onClick={handleClick}>Click Me</button> What interviewers expect A clear definition tied to React in React…
Answer: React wraps native browser events in a SyntheticEvent object for cross-browser compatibility. ✅ Example: function handleClick(e) { console.log(e); // SyntheticEvent } What interviewers expect A clear definition t…
Use controlled components and onChange handlers. ✅ Example: function Form() { const [name, setName] = useState(""); const handleSubmit = e => { e.preventDefault(); console.log(name); }; return ( <form onSubmit={han…
Answer: Hooks are functions that let you "hook into" React state and lifecycle features in functional components. Before hooks, only class components could use state and lifecycle methods. ✅ Hooks introduced in React 16.…
useState lets you add state to functional components. ✅ Syntax: const [state, setState] = useState(initialValue); ✅ Example: import { useState } from 'react'; function Counter() { const [count, setCount] = useState(0); r…
✅ componentDidMount: useEffect(() => { console.log("Component mounted"); }, []); // Empty array = run once on mount ✅ componentWillUnmount: useEffect(() => { const id = setInterval(() => console.log("tick"), 100…
useRef creates a mutable reference that persists across renders. ✅ Syntax: const ref = useRef(initialValue); ✅ Use cases: Accessing DOM elements Persisting values without causing re-renders Storing previous values ✅ Exam…
useContext lets you consume a context value without using a Context.Consumer. ✅ Example: const ThemeContext = React.createContext("light"); function App() { return ( <ThemeContext.Provider value="dark"> <Toolbar…
Custom hooks are just functions that use hooks. ✅ Example: import { useState, useEffect } from 'react'; function useWindowWidth() { const [width, setWidth] = useState(window.innerWidth); useEffect(() => { const handle…
Answer: void recalculating heavy logic on every render. const filteredList = useMemo(() =&gt; { return items.filter(item =&gt; item.includes(searchTerm)); }, [items, searchTerm]); What interviewers expect A clear…
Class Component Pitfall Hook-Based Solution this binding issues ✅ No this in hooks Boilerplate code ✅ More concise with hooks Sharing logic ✅ Custom hooks enable reuse Complex lifecycle logic ✅ useEffect unifies side eff…
Answer: ✅ Create context: const ThemeContext = React.createContext(); ✅ Provide context: &lt;ThemeContext.Provider value="dark"&gt; &lt;App /&gt; &lt;/ThemeContext.Provider&gt; ✅ Consume context:…
Middleware are functions that sit between dispatching an action and reaching the reducer. ✅ Common uses: Handle async operations (API calls) Logging Error handling ✅ Examples: redux-thunk redux-saga redux-logger ✅ Exampl…
ctions Generator-based side effects Complexity Simple Advanced Syntax Imperative (JS functions) Declarative (generators/yield) Use case Basic async logic Complex flows, retries, delays ✅ Thunk example: const fetchUser =…
Redux Toolkit (RTK) is the official, recommended way to write Redux logic. ✅ RTK Benefits: Less boilerplate Built-in createSlice, createAsyncThunk, configureStore Integrated DevTools Handles immutability under the hood ✅…
✅ Using middleware, such as: redux-thunk – lets you dispatch functions redux-saga – handles complex side effects via generators redux-observable – uses RxJS ✅ Example with thunk: const fetchData = () => async (dispatc…
Selectors are functions that read and return data from the store, often with memoization. ✅ Purpose: Centralize access to state shape Avoid duplication Optimize performance ✅ Basic selector: const selectUser = (state) =&…
You can implement routing in React using React Router. Here's how: What interviewers expect A clear definition tied to React in React.js projects Trade-offs (performance, maintainability, security, cost) When you would a…
React.js React.js Tutorial · React
Feature Class
Component
Functional
Component
Syntax ES6 Class Function
State this.state useState hook
Lifecycle methods Yes Use useEffect, etc.
Code size More verbose Cleaner and shorter
✅ Example:
Class:
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}
Functional:
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}React.js React.js Tutorial · React
React’s reconciliation algorithm compares the new Virtual DOM with the old one using a
diffing algorithm. It:
React.js React.js Tutorial · React
Answer: Utility-first CSS framework that uses predefined classes for layout and styling. Great for rapid development.
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
React.js React.js Tutorial · React
Answer: Props (short for "properties") are read-only data passed from a parent component to a child. ✅ Example: function Greeting(props) { return <h1>Hello, {props.name}!</h1>; } <Greeting name="Alice" />
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
React.js React.js Tutorial · React
Answer: Functional component: Use setState from useState. Class component: Use this.setState(). ✅ Example: const [name, setName] = useState("John"); setName("Doe");
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
React.js React.js Tutorial · React
Answer: ✅ Using ternary: {isLoggedIn ? <Logout /> : <Login />} ✅ Using short-circuit: {isVisible && <Sidebar />}
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
React.js React.js Tutorial · React
Answer: Fragments let you return multiple elements without adding an extra DOM node. ✅ Example: <> <h1>Title</h1> <p>Description</p> </> 🔍 Equivalent to <React.Fragment> but shorter.
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
React.js React.js Tutorial · React
Answer: React uses camelCase syntax and passes functions directly. ✅ Example: <button onClick={handleClick}>Click Me</button>
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
React.js React.js Tutorial · React
Answer: React wraps native browser events in a SyntheticEvent object for cross-browser compatibility. ✅ Example: function handleClick(e) { console.log(e); // SyntheticEvent }
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
React.js React.js Tutorial · React
Use controlled components and onChange handlers.
✅ Example:
function Form() {
const [name, setName] = useState("");
const handleSubmit = e => {
e.preventDefault();
console.log(name);
};
return (
<form onSubmit={handleSubmit}>
<input value={name} onChange={e => setName(e.target.value)} />
<button type="submit">Submit</button>
</form>
);
}React.js React.js Tutorial · React
Answer: Hooks are functions that let you "hook into" React state and lifecycle features in functional components. Before hooks, only class components could use state and lifecycle methods. ✅ Hooks introduced in React 16.8.
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
React.js React.js Tutorial · React
useState lets you add state to functional components.
✅ Syntax:
const [state, setState] = useState(initialValue);
✅ Example:
import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
Count: {count}
</button>
);
}React.js React.js Tutorial · React
✅ componentDidMount:
useEffect(() => {
console.log("Component mounted");
}, []); // Empty array = run once on mount
✅ componentWillUnmount:
useEffect(() => {
const id = setInterval(() => console.log("tick"), 1000);
return () => {
clearInterval(id); // Cleanup
console.log("Component unmounted");
};
}, []);
React.js React.js Tutorial · React
useRef creates a mutable reference that persists across renders.
✅ Syntax:
const ref = useRef(initialValue);
✅ Use cases:
✅ Example (DOM access):
const inputRef = useRef();
function focusInput() {
inputRef.current.focus();
}
return <input ref={inputRef} />;
✅ Example (storing previous state):
const prevCount = useRef();
useEffect(() => {
prevCount.current = count;
});
React.js React.js Tutorial · React
useContext lets you consume a context value without using a Context.Consumer.
✅ Example:
const ThemeContext = React.createContext("light");
function App() {
return (
<ThemeContext.Provider value="dark">
<Toolbar />
</ThemeContext.Provider>
);
}
function Toolbar() {
const theme = useContext(ThemeContext);
return <div className={`theme-${theme}`}>Theme is {theme}</div>;
}React.js React.js Tutorial · React
Custom hooks are just functions that use hooks.
✅ Example:
import { useState, useEffect } from 'react';
function useWindowWidth() {
const [width, setWidth] = useState(window.innerWidth);
useEffect(() => {
const handleResize = () => setWidth(window.innerWidth);
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
return width;
}
// Usage
function Component() {
const width = useWindowWidth();
return <p>Window width: {width}</p>;
}React.js React.js Tutorial · React
Answer: void recalculating heavy logic on every render. const filteredList = useMemo(() => { return items.filter(item => item.includes(searchTerm)); }, [items, searchTerm]);
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
React.js React.js Tutorial · React
Class Component
Pitfall
Hook-Based Solution
this binding issues ✅ No this in hooks
Boilerplate code ✅ More concise with hooks
Sharing logic ✅ Custom hooks enable reuse
Complex lifecycle logic ✅ useEffect unifies side
effects
✅ Hooks lead to simpler, more readable, and reusable code.
React State Management – Redux,
Context API, and More
React.js React.js Tutorial · React
Answer: ✅ Create context: const ThemeContext = React.createContext(); ✅ Provide context: <ThemeContext.Provider value="dark"> <App /> </ThemeContext.Provider> ✅ Consume context: const theme = useContext(ThemeContext);
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
React.js React.js Tutorial · React
Middleware are functions that sit between dispatching an action and reaching the
reducer.
✅ Common uses:
✅ Examples:
✅ Example (redux-logger):
const logger = store => next => action => {
console.log('dispatching', action);
return next(action);
};
React.js React.js Tutorial · React
ctions
Generator-based side effects
Complexity Simple Advanced
Syntax Imperative (JS functions) Declarative (generators/yield)
Use case Basic async logic Complex flows, retries, delays
✅ Thunk example:
const fetchUser = () => (dispatch) => {
fetch("/api/user")
.then(res => res.json())
.then(data => dispatch({ type: "SET_USER", payload: data }));
};
React.js React.js Tutorial · React
Redux Toolkit (RTK) is the official, recommended way to write Redux logic.
✅ RTK Benefits:
✅ Example:
const counterSlice = createSlice({
name: 'counter',
initialState: 0,
reducers: {
increment: (state) => state + 1,
},
});
export const { increment } = counterSlice.actions;React.js React.js Tutorial · React
✅ Using middleware, such as:
✅ Example with thunk:
const fetchData = () => async (dispatch) => {
const response = await fetch('/data');
const data = await response.json();
dispatch({ type: 'SET_DATA', payload: data });
};
React.js React.js Tutorial · React
Selectors are functions that read and return data from the store, often with memoization.
✅ Purpose:
✅ Basic selector:
const selectUser = (state) => state.user;
✅ With reselect:
import { createSelector } from 'reselect';
const selectCartItems = (state) => state.cart.items;
const selectTotalPrice = createSelector(
[selectCartItems],
(items) => items.reduce((sum, item) => sum + item.price, 0)
);
React Routing
React.js React.js Tutorial · React
You can implement routing in React using React Router. Here's how:
In a production React.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.