用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/belos-street/skill-kit --skill zustand命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | zustand |
| title | Zustand State Management |
| description | Modern, lightweight state management for React |
| icon | 🗄️ |
| tags | ["react","state-management","zustand"] |
Zustand is a small, fast and scalable state-management solution using simplified flux principles. It has a comfy API based on hooks, isn't boilerplatey or opinionated.
npm install zustand
# or
yarn add zustand
# or
pnpm add zustand
import { create } from 'zustand'
interface CounterState {
count: number
increment: () => void
decrement: () => void
}
const useCounterStore = create<CounterState>((set) => ({
count: 0,
increment: () => set((state) => ({ count: state.count + 1 })),
decrement: () => set((state) => ({ count: state.count - 1 })),
}))
function Counter() {
const { count, increment, decrement } = useCounterStore()
return (
<div>
<p>Count: {count}</p>
<button onClick={increment}>+</button>
<button onClick={decrement}>-</button>
</div>
)
}
function Count() {
const count = useCounterStore((state) => state.count)
return <div>{count}</div>
}
function Controls() {
const { increment, decrement } = useCounterStore()
return (
<>
<button onClick={increment}>+</button>
<button onClick={decrement}>-</button>
</>
)
}
const useUserStore = create<UserState>((set) => ({
user: null,
isLoading: false,
error: null,
fetchUser: async (id: string) => {
set({ isLoading: true, error: null })
try {
const response = await api.getUser(id)
set({ user: response.data, isLoading: false })
} catch (error) {
set({ error: error as Error, isLoading: false })
}
},
}))
import { persist, devtools } from 'zustand/middleware'
const useStore = create(
devtools(
persist(
(set) => ({
// store implementation
}),
{ name: 'app-storage' }
)
)
)
基于 SOC 职业分类