zustand-5

Apply Zustand 5 patterns with TypeScript interfaces and middleware for React state management.

3|Updated Apr 5, 2023
One-click install
npx skills add https://github.com/mrp4sten/.dotfiles --skill zustand-5-mrp4sten
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zustand-5
Source: https://github.com/mrp4sten/.dotfiles/tree/main/development/IA/opencode/skill/zustand-5
Command: npx skills add https://github.com/mrp4sten/.dotfiles --skill zustand-5-mrp4sten

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Zustand 5 patterns help manage React state more predictably and efficiently, reducing boilerplate and re-renders.

Core Features & Use Cases

  • Basic Store: simple shared state across components.
  • Persist Middleware, Selectors, Async Actions, Slices, Immer Middleware, DevTools, and Outside React usage to illustrate a comprehensive state-management approach in real-world apps.

Quick Start

Define a small counter store that persists state and demonstrates selective subscriptions.

Frequently Asked Questions about zustand-5

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage React state with Zustand 5 using persisted settings and selectors?

Manage React state with Zustand 5 by applying persist middleware for settings storage and selective subscriptions to prevent extra re-renders. Define TypeScript interfaces for store shapes and use selectors to subscribe only to required state slices.

What is the best way to structure a Zustand store for async data fetching?

Structure a Zustand store for async data fetching using modular slices. Define async actions within slices and integrate devtools middleware to monitor state changes and track asynchronous request resolution across React components.

Does Zustand 5 work with TypeScript and Immer middleware?

Zustand 5 works with TypeScript and Immer middleware. It provides TypeScript interfaces for store definitions and applies Immer middleware to handle immutable state updates predictably within complex React state objects.

How do I access Zustand state outside of React components?

Access Zustand state outside React components by calling the store hook directly. This allows external scripts to read or mutate state, trigger async actions, and manage shared logic independently of the React rendering cycle.

How can I reduce React re-renders when using a global state store?

Reduce React re-renders by using selective subscriptions in your global state store. Selecting specific state properties ensures components only re-render when their subscribed data slice changes, optimizing performance and reactivity.