计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
react-state-management【效率与协作】Select and implement local, global, and server state patterns in React. Use when choosing or implementing state management (Context, Zustand, Redux, React Query) in React.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
useState manually. Let cache source of truth.useActionState for a form's pending/result/error triad instead of three separate useState calls; use useOptimistic to show an optimistic value while a mutation is in flight, reverting on error automatically.useState for simple UI toggles. useReducer for complex state machines.const fullName = ...). No useEffect to sync state.useMemo on context value to prevent unnecessary re-renders (primitive performance tuning belongs in hooks skill).Boundary note:
hooksskill covers primitive API usage (useMemo,useCallbackrules). This skill covers architectural state decisions — which tool to use for which state scope.
function LikeButton({
postId,
initialLiked,
}: {
postId: string;
initialLiked: boolean;
}) {
const [optimisticLiked, setOptimisticLiked] = useOptimistic(initialLiked);
return (
<button
onClick={async () => {
setOptimisticLiked(!optimisticLiked);
await toggleLike(postId);
}}
>
{optimisticLiked ? "Liked" : "Like"}
</button>
);
}
useActionState, not three useState calls.useOptimistic rather than a manual "isSaving" flag.useState.For Zustand, Redux Toolkit, and TanStack Query patterns: See references/REFERENCE.md.
useEffect to sync state.useState.useOptimistic instead of a hand-rolled temporary state + rollback.