Learning Objectives
By the end of this module, you’ll understand:- When to choose Redux Toolkit vs. Zustand (and why Zustand often wins for mobile)
- Redux Toolkit setup with typed slices
- Zustand for lightweight, performant state
- State persistence patterns for mobile apps
- Common pitfalls with global state on React Native
Choosing a State Library
The React Native ecosystem offers many global state libraries, but two dominate production apps: Redux Toolkit and Zustand. Think of them as a pickup truck vs. a sports car — both get you there, but they are optimized for different jobs.
The practical recommendation: Start with Zustand for new React Native projects. Its tiny footprint matters on mobile, and its API is simpler to onboard teammates with. Reach for Redux Toolkit when you need its middleware ecosystem (RTK Query, listener middleware) or when your team already has Redux expertise.
Redux Toolkit
Installation
Store Configuration
Typed Slice Example
Typed Hooks
Zustand
Installation
Basic Store
Zustand stores are plain functions — no providers, no reducers, no action types. You callcreate, define your state and actions in one place, and consume it with a hook.
Real-World Store with Async Actions
Selective Subscriptions (Performance)
One of Zustand’s biggest advantages on mobile is that components only re-render when the specific value they subscribe to changes.Best Practices
- One store per domain, not one giant store — Create separate Zustand stores for auth, projects, UI preferences, etc. This keeps each store focused and prevents unrelated re-renders.
- Never put server data in global state — Use React Query for data from your API. Global stores are for client state (UI preferences, auth tokens, local-only data).
- Persist selectively — Only persist what the user expects to survive an app restart. Transient state like loading flags and error messages should not be persisted.
- Use the functional updater — Always use
set((state) => ...)instead ofset({ ... })when the new state depends on the previous state. This avoids race conditions from rapid state updates.