用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/simstudioai/sim --skill you-might-not-need-a-callback命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | you-might-not-need-a-callback |
| description | Analyze and fix useCallback anti-patterns in your code |
| argument-hint | [scope] [fix=true|false] |
Arguments:
User arguments: $ARGUMENTS
Read before analyzing:
useCallback is only useful when something observes the reference. Ask: does anything care if this function gets a new identity on re-render?
Observers that care about reference stability:
useEffect that lists the function in its deps arrayuseMemo that lists the function in its deps arrayuseCallback that lists the function in its deps arrayReact.memo that receives the function as a propIf none of those apply — if the function is only called inline, or passed to a non-memoized child, or assigned to a native element event — the reference is unobserved and useCallback adds overhead with zero benefit.
<button onClick={fn}>). Nothing re-runs or bails out based on reference identity. Remove useCallback.<button onClick={fn}> — React never does reference equality on native element props. No benefit.useMemo on the return value instead, or restructure.useCallback whose result is in a useEffect dep array — prevents the effect from re-running on every renderuseCallback whose result is in a useMemo dep array — prevents the memo from recomputing on every renderuseCallback whose result is a dep of another useCallback — stabilises a callback chainuseCallback passed to a React.memo-wrapped child — the whole point of the patternuseRef + callback with empty deps that reads the ref inside — correct, do not flag:const idRef = useRef(id)
useEffect(() => { idRef.current = id }, [id])
const fetchData = useCallback(async () => {
// use idRef.current instead of id
}, []) // empty deps because refs are used