Skip to main content
All Engineering Notes
By Yogesh Singh•2026-10-14•6 min read

Eliminating React Re-Renders with Atomic Zustand Slices

How to replace monolithic React Context providers with atomic Zustand selector stores, isolate multi-step Formik conversion flows, and cut client re-render cascades in high-traffic apps like Career247.

Next.jsZustandTypeScriptArchitecture
Key Architectural Takeaways
  • Split client state into domain-scoped Zustand slices with atomic selectors instead of monolithic context providers.
  • Keep Next.js App Router pages as Server Components by default; push 'use client' boundaries to interactive leaves.
  • Pair Formik step validation with externalized draft persistence so campaign traffic never loses conversion progress.

1. Why Context & Prop-Drilling Break Under Campaign Traffic

In high-traffic ed-tech platforms like Career247, landing and enrollment pages combine dynamic course metadata, personalized eligibility checks, and multi-step lead capture forms. Wrapping the tree in a single React Context causes every consumer to re-render whenever a single form field or filter changes.

By moving shared interactive state into Zustand stores accessed via granular selectors, components subscribe strictly to the primitive or slice they render. Combined with Next.js App Router Server Components for static catalog shells, client JavaScript stays minimal.

2. Typed Slice Architecture with Selector Discipline

In TypeScript, a clean store separates state data from actions and exposes custom selector hooks. This prevents accidental whole-store subscriptions during code reviews and keeps components testable.

src/stores/useEnrollmentStore.ts
import { create } from "zustand";

interface EnrollmentState {
  step: 1 | 2 | 3;
  selectedTrackId: string | null;
  setStep: (step: 1 | 2 | 3) => void;
  selectTrack: (trackId: string) => void;
}

export const useEnrollmentStore = create<EnrollmentState>((set) => ({
  step: 1,
  selectedTrackId: null,
  setStep: (step) => set({ step }),
  selectTrack: (selectedTrackId) => set({ selectedTrackId, step: 2 }),
}));

// Atomic selectors prevent unrelated re-renders
export const useCurrentStep = () => useEnrollmentStore((s) => s.step);

3. Isolating Formik Flows & Bundle Boundaries

Multi-step enrollment forms often pull in heavy validation schemas and date/phone utilities. Lazy-loading secondary drawer steps and keeping initial above-the-fold CTAs lightweight ensures mobile users on slower networks hit interactive readiness without waiting on the entire funnel bundle.