State Management
Local vs global state, reducers, stores, context performance and server-state caching.
1.What is the difference between state and props in React?
Props are inputs owned by the parent; state is memory owned by the component.
2.Why does React recommend against mutating state?
Reference equality, memoization, snapshots and concurrent rendering all assume immutability.
3.Pub/Sub Store (Mini Redux)
Implement createStore with getState, dispatch and subscribe: the core of Redux in about 50 lines.
4.Undo/Redo History
Implement an undoable value with past and future stacks, redo invalidation, no-op detection and a bounded history size.
5.What are some pitfalls about using context in React?
Re-render cascades, unstable values, overuse and missing providers.
6.Tic-tac-toe
Build a two-player tic-tac-toe game with win and draw detection, a live status and a keyboard-navigable board.
7.Toast Notifications
Build a toast system with a context API, live-region announcements, auto-dismiss that pauses on hover or focus, and a visible limit.
8.Traffic Light
Build a traffic light that cycles through configurable states with timers, a pause control and clean effect teardown.
9.Backbone Model
Build an observable Model class with defaults, get/set/unset, per-attribute change events, previous values and silent updates.
10.Signals (Fine-Grained Reactivity)
Implement createSignal, createEffect, createMemo, batch and untrack with automatic dependency tracking and glitch-free updates.
11.How would you optimize the performance of React contexts to reduce rerenders?
Stable values, split contexts, state/dispatch separation and selector-based stores.
12.How do you decide between using React state, context, and external state managers?
Classify state as server, URL, local or shared, then pick the simplest fitting tool.
13.Where should a browser app store JWTs or session tokens: localStorage, memory or cookies?
XSS vs CSRF exposure, HttpOnly cookies, in-memory access tokens with refresh rotation, and the BFF pattern.
14.Flight Booker
Build a one-way or return flight form with date constraints, disabled states and a booking confirmation.
15.Mortgage Calculator
Calculate the monthly payment, total cost and total interest of a fixed-rate loan as the user types.
16.How do you model immutability in TypeScript with `readonly`?
readonly modifiers, Readonly, readonly arrays and as const, and their limits.
17.Nested Checkboxes
Build a checkbox tree where parents reflect their children as checked, unchecked or indeterminate.
18.What are JavaScript object property flags and descriptors?
writable, enumerable, configurable, accessor descriptors and how freeze/seal build on them.
19.Progress Bars III: Pause and Resume
Queue-limited progress bars that can be paused and resumed without losing progress, driven by one shared clock.