Fähigkeiten zustand-store-ts
📦

zustand-store-ts

Sicher

Build Type-Safe Zustand Stores for React

Managing React state with proper TypeScript types and middleware is complex. This skill provides proven patterns for creating maintainable Zustand stores with subscribeWithSelector and clear state/action separation.

UnterstĂĽtzt: Claude Codex Code(CC)
🥉 75 Bronze
1

Die Skill-ZIP herunterladen

2

In Claude hochladen

Gehe zu Einstellungen → Fähigkeiten → Skills → Skill hochladen

3

Einschalten und loslegen

Teste es

Verwendung von "zustand-store-ts". Create a counter store with increment, decrement, and reset actions

Erwartetes Ergebnis:

A TypeScript store interface with count state and three action methods, plus the create() implementation with subscribeWithSelector middleware wrapped around the store definition.

Verwendung von "zustand-store-ts". How do I subscribe to only the userId change?

Erwartetes Ergebnis:

Use store.subscribe((state) => state.userId, (id) => console.log(id)) to receive callbacks only when userId changes, avoiding unnecessary executions for other state updates.

Sicherheitsaudit

Sicher
v1 • 2/25/2026

Static analysis flagged 19 patterns (14 external_commands, 5 blocker/crypto), but all are false positives. The backticks detected are markdown code fence delimiters for TypeScript examples, not shell execution. The cryptographic warnings reference 'subscribeWithSelector' text patterns, not actual crypto algorithms. This is a documentation-only skill with code examples for Zustand state management.

1
Gescannte Dateien
74
Analysierte Zeilen
0
befunde
1
Gesamtzahl Audits
Keine Sicherheitsprobleme gefunden
Auditiert von: claude

Qualitätsbewertung

38
Architektur
100
Wartbarkeit
87
Inhalt
50
Community
100
Sicherheit
100
Spezifikationskonformität

Was du bauen kannst

React Developer Building Global State

Create a new Zustand store for managing application-wide state like user sessions, themes, or feature flags with full TypeScript support.

Team Standardizing State Patterns

Establish consistent store patterns across a codebase with proper typing, middleware usage, and subscription best practices.

Migrating from Redux to Zustand

Convert existing Redux stores to lightweight Zustand stores while maintaining TypeScript types and optimizing re-renders.

Probiere diese Prompts

Basic Store Creation
Create a Zustand store template for a shopping cart with items array and total price calculation. Use TypeScript and include the subscribeWithSelector middleware.
Store with Async Actions
Generate a user store with async login and logout actions. Include proper TypeScript interfaces for state and actions, with loading and error states.
Complex Store with Selectors
Create a project management store with tasks, filters, and computed selectors. Show how to use individual selectors to prevent unnecessary re-renders.
Non-React Subscription
Show how to subscribe to store changes outside React components for logging or integration with external systems like analytics.

Bewährte Verfahren

  • Always wrap stores with subscribeWithSelector middleware for granular subscriptions
  • Define separate interfaces for state and actions, then combine them for the store type
  • Use selector functions in components to subscribe only to needed state slices

Vermeiden

  • Destructuring the entire store in components causes re-renders on any state change
  • Creating stores without TypeScript interfaces loses type safety benefits
  • Subscribing to the entire state object when only one property is needed

Häufig gestellte Fragen

Why use subscribeWithSelector instead of the default middleware?
subscribeWithSelector enables granular subscriptions that only trigger when specific state properties change, improving performance by avoiding unnecessary re-renders and callback executions.
Should I create one store or multiple stores?
Start with separate stores for unrelated domains (user, cart, settings). Combine related state in a single store when actions frequently update multiple properties together.
How do I handle async actions in Zustand?
Define async functions in your actions interface. Inside the implementation, use async/await syntax and call set() with the updated state after the async operation completes.
Can I use Zustand stores outside React components?
Yes, stores can be imported and used anywhere. Use the subscribe method to listen for changes in non-React code, such as utilities, services, or analytics integrations.
What is the difference between get() and direct state access?
get() provides the current store state inside actions without subscribing to updates. It is useful for accessing fresh state values during action execution without triggering re-renders.
Do I need to clean up subscriptions manually?
Yes, store.subscribe returns an unsubscribe function. Call it when the subscription is no longer needed, such as in useEffect cleanup or when destroying external listeners.

Entwicklerdetails

Dateistruktur

đź“„ SKILL.md