State Management

Junior Questions

Junior
4

How does React Context API work?

Context provides a way to pass data through the component tree without having to pass props down manually at every level. Useful for themes, locales, and simple global state.

What problems does this solve?

  • Understanding where Context fits vs a specialized state library is a common senior discussion.
Junior
6

Local vs Global State?

Local state is internal to a single component (e.g., whether a toggle is open). Global state is shared across multiple components throughout the application (e.g., user authentication info).

What problems does this solve?

  • Deciding where state should live is one of the most common architectural decisions in frontend dev.
Junior
17

UI vs Server State?

UI state (client state) includes ephemeral data like form inputs or current selection. Server state is data that lives on the server and is fetched via APIs, necessitating handling for loading and error states.

What problems does this solve?

  • Modern apps distinguish between client and server state for better performance and DX.
Junior
18

Vue Reactivity (ref/reactive)?

Vue's reactivity system uses Proxies to track changes automatically. `ref` is for single values; `reactive` is for objects. They form the basis of all Vue state.

What problems does this solve?

  • Understanding Proxies vs the old `Object.defineProperty` is a standard senior Vue question.
Junior
23

What is Pinia (Vue)?

Pinia is the store library for Vue, providing a simple, type-safe API for managing global state. It's the official successor to Vuex and works seamlessly with the Composition API.

What problems does this solve?

  • Knowing the modern standard for Vue state management shows currency in the ecosystem.
Junior
24

What is State Management?

State management refers to the practice of managing and maintaining the values of variables and data across an application. It ensures that the application's UI reflects the current state of the data accurately.

What problems does this solve?

  • Fundamental understanding of why we need state management is where most technical discussions start.
Junior
27

What is the Flux Pattern?

Flux is an architectural pattern for building web applications that emphasizes a unidirectional data flow: Actions -> Dispatcher -> Store -> View.

What problems does this solve?

  • Understanding Flux is necessary context for why Redux and other modern libraries exist.
Junior
28

What is the Reducer Pattern?

A reducer is a pure function that takes the current state and an action, and returns a new state. This pattern allows for predictable and testable state transitions.

What problems does this solve?

  • The reducer pattern is used in everything from `useReducer` to Redux and even some Vue patterns.
Junior
30

useState vs useReducer?

`useState` is best for simple values and local component state. `useReducer` is better when you have complex state logic, multiple sub-values, or when the next state depends on the previous one.

What problems does this solve?

  • Knowing when to scale from `useState` to `useReducer` is a practical skill for React developers.

Mid-Level Questions

Mid
1

Choosing a State Library?

Decision criteria: App size, team experience, built-in vs third party, frequency of updates, and type of state (server vs UI).

What problems does this solve?

  • The ability to weigh trade-offs and justify library choice is a key differentiator for senior roles.
Mid
2

Composable State?

Composables allow sharing stateful logic between components. If state is declared *outside* the function, it becomes shared "global" state for everyone calling it.

What problems does this solve?

  • Composables are Vue's equivalent to React Hooks; they power the most robust patterns in the ecosystem.
Mid
3

Context API vs Redux?

Context is built-in and great for "low-frequency" updates (themes, users). Redux/Zustand provide optimized updates for "high-frequency" data, better debugging tools, and middleware for side effects.

What problems does this solve?

  • Avoiding "Context overuse" is a key architectural tip mentioned in many interviews.
Mid
5

Importance of Immutability?

Immutability ensures that state is never modified directly, but instead replaced with a new version. This makes state transitions predictable and enables features like time-travel debugging.

What problems does this solve?

  • Immutability is a core pillar of frameworks like React for efficient change detection.
Mid
7

Mutations vs Queries?

Queries fetch data (READ). Mutations change data (WRITE). This distinction is fundamental to libraries like TanStack Query and GraphQL.

What problems does this solve?

  • Correct terminology shows professional exposure to standardized API communication.
Mid
8

Optimistic Updates?

Update the UI as if an API call has succeeded before getting the response. If the call fails, the change is rolled back. This makes an application feel instant.

What problems does this solve?

  • Optimistic updates provide the "premium" feel that distinguishes high-quality PWAs.
Mid
9

Pinia vs Vuex?

Pinia is the modern alternative to Vuex. It is simpler (no mutations), fully type-safe, and designed for use with the Composition API.

What problems does this solve?

  • Identifying that mutations were redundant in Vue 3 is key to understanding Pinia's design.
Mid
12

Redux Core Concepts?

Redux is built on three core principles: a single source of truth (the State), state is read-only (Actions), and changes are made with pure functions (Reducers).

What problems does this solve?

  • Redux popularized unidirectional data flow and pure functions in frontend development.
Mid
13

Server State in Vue?

Vue developers often use `useAsyncData` (Nuxt) or TanStack Query for Vue to manage caching and synchronization of server data.

What problems does this solve?

  • Recognizing that Nuxt has built-in server state management is important for Nuxt-specific roles.
Mid
14

Stale-While-Revalidate?

A cache invalidation strategy where the browser handles returning stale cached data first and then fetching a background "revalidation" update.

What problems does this solve?

  • Understanding this pattern is necessary for explaining data consistency vs load performance.
Mid
16

TanStack Query (React)?

TanStack Query (formerly React Query) is an asynchronous state management library that takes away the struggle of fetching, caching, synchronizing and updating server state.

What problems does this solve?

  • Knowing that data-fetching libraries should be separated from UI-state libraries is a hallmark of good architecture.
Mid
19

What are Signals?

Signals (Preact/Solid/Qwik) provide a way to store state that allows the framework to update only the specific parts of the DOM that changed, bypassing component re-rendering entirely.

What problems does this solve?

  • Signals are the latest "big thing" in reactive performance; knowing how they work shows depth.
Mid
22

What is Derived State?

Derived state is data that can be calculated entirely from existing state. It should not be stored separately but computed on-the-fly to prevent sync issues.

What problems does this solve?

  • Avoiding redundant state is the easiest way to prevent bugs where parts of the UI get out of sync.
Mid
26

What is Zustand?

Zustand is a tiny, fast, and scalable bearbones state-management solution using simplified flux principles. It is popular because it has zero boilerplate and uses hooks naturally.

What problems does this solve?

  • Zustand is currently the leading alternative to Redux for general-purpose state management in React.

Senior Questions

Senior
10

Production Best Practices?

Checklist: keep state normalized, favor local state by default, use computed/selectors for derived values, implement optimistic updates for better feel, and monitor for memory leaks.

What problems does this solve?

  • Concluding with a set of rules for high-scale apps shows architectural maturity.
Senior
11

Recoil/Jotai Atoms?

Atoms-based libraries use a "distributed" state model where state is broken into tiny pieces (atoms) that components can subscribe to individually, minimizing unnecessary re-renders.

What problems does this solve?

  • Atom-based state represents a different mental model from "one big store" Flux.
Senior
15

State Serialization?

The process of converting state to a format (like JSON string) that can be stored in localStorage or sent over the wire. Values like Functions or Sets cannot be serialized directly.

What problems does this solve?

  • Understanding serialization limits is vital for implementing state persistence properly.
Senior
20

What are State Machines (XState)?

A state machine defines a finite set of states (Idle, Loading, Success, Error) and explicit transitions between them, preventing impossible states.

What problems does this solve?

  • State machines provide the ultimate level of predictability for complex UI flows (e.g., checkout).
Senior
21

What is Cache Invalidation?

The process of declaring cached data as stale or incorrect. In state management, this triggers a re-fetch to ensure the client stays in sync with the server.

What problems does this solve?

  • Cache invalidation is famously one of the hardest problems in computer science.
Senior
25

What is State Normalization?

Storing state in a flat format, often by ID, similar to a database. This avoids deeply nested structures and makes updates more efficient.

What problems does this solve?

  • Normalization is a senior requirement for building applications that handle large, interconnected datasets.
Senior
29

Why use the URL as State?

Keeping sort/filter/page parameters in the URL ensures that users can bookmark pages or share links while preserving the exact state of the UI.

What problems does this solve?

  • URL-driven state is an accessibility and UX requirement for anything with data filters.