frontend-state-management by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill frontend-state-management使用现代模式和库来实现可扩展的状态管理解决方案,以处理应用程序状态、副作用以及跨组件的数据流。
最小工作示例:
// store/userSlice.ts
import { createSlice, createAsyncThunk, PayloadAction } from '@reduxjs/toolkit';
interface User {
id: number;
name: string;
email: string;
}
interface UserState {
items: User[];
loading: boolean;
error: string | null;
}
const initialState: UserState = {
items: [],
loading: false,
error: null
};
export const fetchUsers = createAsyncThunk(
'users/fetchUsers',
async (_, { rejectWithValue }) => {
try {
// ... (完整实现请参阅参考指南)
references/ 目录下的详细实现:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 指南 | 内容 |
|---|
| Redux with Redux Toolkit (React) | Redux with Redux Toolkit (React) |
| Zustand (轻量级状态管理) | Zustand (轻量级状态管理) |
| Context API + useReducer | Context API + useReducer |
| MobX (可观察状态) | MobX (可观察状态) |
每周安装量
120
代码仓库
GitHub 星标数
116
首次出现
2026年1月21日
安全审计
已安装于
opencode103
gemini-cli87
codex85
claude-code84
cursor80
github-copilot73
Implement scalable state management solutions using modern patterns and libraries to handle application state, side effects, and data flow across components.
Minimal working example:
// store/userSlice.ts
import { createSlice, createAsyncThunk, PayloadAction } from '@reduxjs/toolkit';
interface User {
id: number;
name: string;
email: string;
}
interface UserState {
items: User[];
loading: boolean;
error: string | null;
}
const initialState: UserState = {
items: [],
loading: false,
error: null
};
export const fetchUsers = createAsyncThunk(
'users/fetchUsers',
async (_, { rejectWithValue }) => {
try {
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Redux with Redux Toolkit (React) | Redux with Redux Toolkit (React) |
| Zustand (Lightweight State Management) | Zustand (Lightweight State Management) |
| Context API + useReducer | Context API + useReducer |
| MobX (Observable State) | MobX (Observable State) |
Weekly Installs
120
Repository
GitHub Stars
116
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode103
gemini-cli87
codex85
claude-code84
cursor80
github-copilot73
TanStack Query v5 完全指南:React 数据管理、乐观更新、离线支持
2,500 周安装