重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
redux by teachingai/full-stack-skills
npx skills add https://github.com/teachingai/full-stack-skills --skill redux当用户希望实现以下目标时,请使用此技能:
createSlice 创建切片,并使用 configureStore 配置 storecreateAsyncThunk 或 RTK Query 处理异步逻辑useSelector 和 useDispatch 钩子createSlice 创建切片广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
useSelectoruseDispatchimport { createSlice, PayloadAction } from '@reduxjs/toolkit';
interface CounterState {
value: number;
}
const initialState: CounterState = { value: 0 };
const counterSlice = createSlice({
name: 'counter',
initialState,
reducers: {
increment(state) { state.value += 1; },
decrement(state) { state.value -= 1; },
incrementByAmount(state, action: PayloadAction<number>) {
state.value += action.payload;
},
},
});
export const { increment, decrement, incrementByAmount } = counterSlice.actions;
export default counterSlice.reducer;
import { configureStore } from '@reduxjs/toolkit';
import counterReducer from './counterSlice';
export const store = configureStore({
reducer: {
counter: counterReducer,
},
});
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
import { useSelector, useDispatch } from 'react-redux';
import { RootState, AppDispatch } from './store';
import { increment, decrement } from './counterSlice';
export function Counter() {
const count = useSelector((state: RootState) => state.counter.value);
const dispatch = useDispatch<AppDispatch>();
return (
<div>
<p>Count: {count}</p>
<button onClick={() => dispatch(increment())}>+</button>
<button onClick={() => dispatch(decrement())}>-</button>
</div>
);
}
import { createAsyncThunk } from '@reduxjs/toolkit';
export const fetchUsers = createAsyncThunk('users/fetch', async () => {
const response = await fetch('/api/users');
return response.json();
});
createSlice、configureStore)而非手写样板代码createAsyncThunk 或 RTK Query 处理异步操作;切勿在 reducers 中获取数据useAppSelector、useAppDispatch)以实现类型安全访问redux, Redux Toolkit, createSlice, configureStore, createAsyncThunk, RTK Query, useSelector, useDispatch, state management, middleware, store, actions, reducers
周安装量
70
代码仓库
GitHub 星标数
242
首次出现
2026年1月24日
安全审计
安装于
opencode63
gemini-cli39
codex38
claude-code35
github-copilot35
amp32
Use this skill whenever the user wants to:
createSlice and configure the store with configureStorecreateAsyncThunk or RTK QueryuseSelector and useDispatch hooks in React componentscreateSliceuseSelector and useDispatchimport { createSlice, PayloadAction } from '@reduxjs/toolkit';
interface CounterState {
value: number;
}
const initialState: CounterState = { value: 0 };
const counterSlice = createSlice({
name: 'counter',
initialState,
reducers: {
increment(state) { state.value += 1; },
decrement(state) { state.value -= 1; },
incrementByAmount(state, action: PayloadAction<number>) {
state.value += action.payload;
},
},
});
export const { increment, decrement, incrementByAmount } = counterSlice.actions;
export default counterSlice.reducer;
import { configureStore } from '@reduxjs/toolkit';
import counterReducer from './counterSlice';
export const store = configureStore({
reducer: {
counter: counterReducer,
},
});
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
import { useSelector, useDispatch } from 'react-redux';
import { RootState, AppDispatch } from './store';
import { increment, decrement } from './counterSlice';
export function Counter() {
const count = useSelector((state: RootState) => state.counter.value);
const dispatch = useDispatch<AppDispatch>();
return (
<div>
<p>Count: {count}</p>
<button onClick={() => dispatch(increment())}>+</button>
<button onClick={() => dispatch(decrement())}>-</button>
</div>
);
}
import { createAsyncThunk } from '@reduxjs/toolkit';
export const fetchUsers = createAsyncThunk('users/fetch', async () => {
const response = await fetch('/api/users');
return response.json();
});
createSlice, configureStore) instead of hand-written boilerplatecreateAsyncThunk or RTK Query for async operations; never fetch in reducersuseAppSelector, useAppDispatch) for type-safe accessredux, Redux Toolkit, createSlice, configureStore, createAsyncThunk, RTK Query, useSelector, useDispatch, state management, middleware, store, actions, reducers
Weekly Installs
70
Repository
GitHub Stars
242
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode63
gemini-cli39
codex38
claude-code35
github-copilot35
amp32
Vercel React 最佳实践指南 | Next.js 性能优化与代码规范
10,600 周安装