React & JavaScript Core Concepts (Virtual DOM, Lifecycle, Context API, Redux, Event Loop)
viaLeetCode
Q&A covering:
- Virtual DOM: an in-memory representation of the real DOM that React diffs against the previous version to compute and batch the minimal set of real DOM updates, improving performance.
- React Lifecycle: the mounting, updating, and unmounting phases of a component and the hooks/methods (or lifecycle methods in class components) invoked at each phase.
- Context API: a mechanism to pass data through the component tree without manually threading props at every level ("prop drilling"); any update to the context value re-renders all consuming components.
- Redux: a predictable state container with a single global store, plain-object actions describing "what happened", and pure reducer functions computing the next state -- enabling predictable state changes and tooling like time-travel debugging.
- Event Loop / callback functions: the JS runtime model of a single call stack plus a task queue and microtask queue; asynchronous callbacks (timers, promises, I/O) are queued and only run once the call stack is empty, explaining how JS achieves non-blocking concurrency despite being single-threaded.
asked …