Agent skill · software engineering · aiskillstore
rn-zustand-patterns
Zustand state management patterns for React Native. Use when working with Zustand stores, debugging state timing issues, or implementing async actions in Zustand.
Why this skill is useful
Provides specific patterns and best practices for managing state in Zustand that are not widely documented, helping prevent common pitfalls.
What it needs
About 5k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.
What this skill does
Zustand Patterns for React Native Problem Statement Zustand's simplicity hides important timing details. set() is synchronous, but React re-renders are batched. getState() escapes stale closures. Async actions in stores need careful handling. Understanding these internals prevents subtle bugs. --- Pattern: set() is Synchronous, Renders are Batched Problem: Assuming state is "ready" for React immediately after set(). Key insight: set() updates the store synchronously getState() immediately reflects the new value React components re-render asynchronously (batched) When this matters: Chaining multiple state updates Validating state after update Debugging "stale" component values --- Pattern: getState() Escapes Stale Closures Problem: Callbacks and async functions capture state at creation time. Using get() or getState() always gets current state. Rule: After any await, use get() or getState() - never rely on closure-captured values. --- Pattern: Async Actions in Stores Problem: Async actions need explicit async/await and careful state reads after awaits. --- Pattern: Selector Stability Problem: Selectors that create new objects cause unnecessary re-renders. --- Pattern: Derived State Problem: Computing derived values in selectors vs storing them. --- Pattern: Store Subscriptions for Side Effects Problem: Need to react to state changes outside React components. --- Pattern: Testing Zustand Stores Problem: Tests need to reset store state and verify async flows. --- Pattern: Debugging State Changes Problem: Tracking down when/where state changed unexpectedly. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills aiskillstore/rn-zustand-patterns