Back
Web Fundamentals

Redux: Predictable State Container (RTK + RTK Query)

Web Fundamentals
Build & Deployment: Monorepo, CI/CD, Strategies & Release SafetyState Management: Choosing the Right SolutionRedux: Predictable State Container (RTK + RTK Query)React Query (TanStack Query): Server State CachingData Fetching Patterns: REST, GraphQL, tRPC & Real-timeGraphQL Fundamentals for Frontend: Shape, Caching, and TradeoffsgRPC-Web Fundamentals: Browser Constraints and Proxy ModelCaching Strategies: Client, Server & EdgeData Normalization: Organizing State for PerformanceAPI Design Best Practices: Pagination, Errors, Versioning & Type SafetyAPI Versioning Strategies for Frontend CompatibilityPagination: Offset vs Cursor-BasedRate Limiting & API Resilience: Retries, Backoff, Jitter, IdempotencyHow Frontend Developers Can Handle Millions of API Requests Without Crashing EverythingBrowser Storage: Cookies, SessionStorage, LocalStorage, IndexedDBReal-time Communication: WebSockets, SSE & PollingWebRTC: Real-Time Communication in the BrowserCore Web Vitals: LCP, INP & CLSPerformance Optimization Trade-offsCritical Resource Prioritization: Optimize Loading OrderCode Splitting: Optimize Bundle Size with Dynamic ImportsTree Shaking: Eliminate Dead Code from Your BundleLazy Loading: Load Resources On-DemandResource Hints: Preload, Prefetch & PreconnectText Compression: Gzip and BrotliImage & Video Optimization: Modern Formats & TechniquesAdaptive Loading: Optimize for Device & NetworkList Virtualization: Render Large Lists EfficientlyWeb Workers vs Main Thread: Offloading Heavy WorkMemory Leaks in Frontend Apps: Detection & PreventionManaging Third-Party Scripts: Optimization StrategiesHow CDNs Work: Edge Delivery, Caching & PerformanceHTTP Caching Deep Dive: Cache-Control, ETag & RevalidationService Workers & Offline Strategy: Cache First, Network First & Update LifecyclePWA Fundamentals: Manifest, Installability & Offline UXCritical Rendering PathScript Loading: async vs deferEvent Loop: Understanding JavaScript Execution ModelJavaScript Module Systems: CJS vs ESM vs UMDDynamic Module Loading: import() FunctionImport on Interaction: Load When User InteractsImport on Visibility: Lazy Loading with IntersectionObserverBrowser Rendering Pipeline & Layout ThrashingRendering Strategies: CSR vs SSR vs SSG vs ISRStreaming SSR: Progressive HTML StreamingIslands Architecture: Independent Component HydrationReact Server Components: Zero-JS Server RenderingFramework Reactivity: React, Vue, Svelte & SolidHTTP/1.1 vs HTTP/2 vs HTTP/3 (QUIC) for Frontend PerformanceDNS Resolution: Path, TTL, Caching & Frontend ImpactCross-Site Scripting (XSS) AttacksCross-Site Request Forgery (CSRF) AttacksCORS Explained: Cross-Origin Resource SharingCORS Preflight in Practice: Credentials, Simple Requests & MisconfigurationsContent Security Policy (CSP)Why is HTTPS Secure? Understanding TLS/SSLAuthorization Best PracticesCookie Security & Session Hardening: SameSite, HttpOnly, Secure
mediumFrontend Architecture

Redux: Predictable State Container (RTK + RTK Query)

TL;DRRedux Toolkit for complex shared state. RTK Query for server data. Use selectors + normalization for performance.
High Signal
Google
Meta
Netflix
Agoda
30-Second Answerstart every interview with this

Redux provides predictable state updates and excellent debugging. Modern Redux = Redux Toolkit (slices, configureStore, createAsyncThunk) + RTK Query for server state. Use it when you need strong architecture for complex shared state and large teams.

The store is the single source of truth. Actions are formal requests to change state. Reducers are the only editors allowed to update the store. This predictability makes debugging and testing much easier at scale.

UI dispatches action
Reducer computes new state (Immer allows 'mutation')
Selectors compute derived views
Components re-render only when needed

1Redux Toolkit Patterns

Use createSlice for state + reducers + actions. configureStore for store setup. createAsyncThunk for async logic.

counterSlice.tsts
import { createSlice } from '@reduxjs/toolkit';

const counterSlice = createSlice({
  name: 'counter',
  initialState: { value: 0 },
  reducers: {
    increment: (state) => { state.value += 1 }
  }
});

export const { increment } = counterSlice.actions;
export default counterSlice.reducer;

2Performance: Normalization + Selectors

Store entities by ID (normalized). Use selectors and createSelector (Reselect) to compute derived data efficiently and prevent unnecessary rerenders.

3RTK Query for Server State

The recommended way to handle API data in Redux. Automatic caching, deduping, invalidation with tags, and optimistic updates.

PropertyRedux ToolkitRTK Query
Best ForComplex shared state, large teamsServer/API data
BoilerplateMedium (structured)Low
PerformanceExcellent with selectorsBuilt-in caching

Redux Toolkit

Best For

Complex shared state, large teams

Boilerplate

Medium (structured)

Performance

Excellent with selectors

RTK Query

Best For

Server/API data

Boilerplate

Low

Performance

Built-in caching

Common questions

  • ›“When should you use Redux vs Zustand or Context?”
  • ›“How do you keep Redux performant at scale?”
  • ›“What is RTK Query and when should you use it?”
  • ›“Explain state normalization in Redux.”

What interviewers look for

  • Clear reasoning for choosing Redux (shared state + team scale)
  • Understanding of normalization and selectors
  • Modern Redux = RTK + RTK Query
  • Performance awareness (selectors, avoiding unnecessary rerenders)

Short answer (60 sec)

Use Redux Toolkit for complex shared state with strong debugging needs. Use RTK Query for server data caching. Keep state normalized and use selectors for performance.

Detailed answer (senior level)

Redux shines in large apps with many shared state flows. Use createSlice and configureStore from Redux Toolkit. For server state, prefer RTK Query over manual thunks. Normalize entities by ID, use createSelector for derived data, and memoize to prevent rerenders. This combination gives predictability, excellent DevTools, and great performance.

  • Using Redux for simple apps (overkill)
  • Storing server data manually instead of using RTK Query
  • Selecting large state objects (causes rerenders)
  • Not normalizing data (deep nesting)
  • Scattering async logic across components
Key Takeaways
  • ✓Redux = predictable shared state container
  • ✓Modern Redux = Redux Toolkit everywhere
  • ✓RTK Query = best for server/API state
  • ✓Normalize entities by ID for performance
  • ✓Use selectors (createSelector) to avoid rerenders
  • ✓Redux is a team-scale and debugging tool
  • ✓Measure and optimize based on real rerender patterns
Previous TopicState Management: Choosing the Right SolutionNext Topic React Query (TanStack Query): Server State Caching

On this page