Loading content…
Loading content…
A comprehensive compilation of top React interview questions and detailed answers categorized by Junior, Mid, and Senior levels
| Property | Props | State |
|---|---|---|
| Source | Passed by Parent | Declared inside Component |
| Mutable? | ❌ Read-Only | ✅ Mutable (via setState) |
| Triggers Render? | Yes (if parent passes new props) | Yes (when state updates) |
ref (Reference).// Controlled Component
const ControlledInput = () => {
const [value, setValue] = useState("");
return <input value={value} onChange={e => setValue(e.target.value)} />;
};
// Uncontrolled Component
const UncontrolledInput = () => {
const inputRef = useRef<HTMLInputElement>(null);
const handleSubmit = () => {
console.log(inputRef.current?.value); // Direct DOM read
};
return <input ref={inputRef} />;
};
UserContext and ThemeContext).React.memo.useMemo returns a memoized value (caches the result of a calculation).useCallback returns a memoized function reference (caches the function itself).// useMemo: caches the result (number/object)
const computedValue = useMemo(() => computeHeavyValue(a, b), [a, b]);
// useCallback: caches the function signature/reference
const handleClick = useCallback(() => { doSomething(a); }, [a]);
useEffect to clear timeouts, event listeners, and WebSockets.react-window) to reduce DOM nodes.AbortController.Pro Tip
React Interview Must-Known Topics
Marking it complete updates your roadmap progress percentage.