Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问许可证需确认审计通过

react-hookReact hook 搜索

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

642

周安装

27

GitHub Stars

8

下载量

225
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:react-hook(React hook 搜索)
来源仓库:https://github.com/bumgeunsong/daily-writing-friends
仓库路径:skills/react-hook
安装命令:
npx skills add https://github.com/bumgeunsong/daily-writing-friends --skill react-hook
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/bumgeunsong/daily-writing-friends --skill react-hook

简介

专门搜索 React Hook 使用案例和实现技巧。

  • 适用于自定义 Hook 设计和复用模式查询。react-hook 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 提供常见场景如数据获取、表单和副作用管理的方案。
  • 通过 GitHub 安装,示例代码需适配项目技术栈。
  • 建议在实现前先验证 Hook 是否符合预期行为。

SKILL.md

React Hook Patterns

Overview

Core principles:

  • Callbacks passed to hooks must be wrapped in useCallback
  • One hook per file, organized by feature domain
  • Only abstract when logic is reused or complex

Custom Hook Rules

RuleWhy
Must start with useReact's hook detection
One hook per fileMaintainability
Never call conditionallyBreaks hook order
Never return side effectsUnpredictable behavior
Type inputs and outputsClarity and safety
Test in isolationReliability

On memoization: Only use useMemo/useCallback when logic is computationally heavy. Otherwise they degrade readability without meaningful benefit. Exception: callbacks passed TO hooks (see stability section below).

When to Use

  • Passing a callback to a custom hook
  • Fixing react-hooks/exhaustive-deps ESLint warnings
  • Debugging "why is this re-rendering every keystroke?"
  • Seeing errors like addRange(): The given range isn't in document

The Problem

Inline callback → Hook depends on it → Hook's output in useMemo → Cascade of re-renders

When you fix an ESLint exhaustive-deps warning by adding a dependency, check if that dependency is STABLE. If not, you've created a re-render loop.

Core Pattern

// ❌ BAD - inline function recreated every render
const { handler } = useCustomHook({
  onComplete: (result) => doSomething(result)
});

// ✅ GOOD - stable reference
const onComplete = useCallback((result) => doSomething(result), []);
const { handler } = useCustomHook({ onComplete });

Quick Reference

SituationAction
Passing callback to hookWrap in useCallback
ESLint says add dependencyCheck if dependency is stable first
Hook output changes every renderTrace dependency chain backwards
Component re-renders on every keystrokeCheck for inline callbacks in hook calls

Red Flags - STOP and Check

If you're about to:

  • Pass an inline arrow function to a custom hook
  • Add a callback to useMemo/useCallback deps without checking stability
  • "Fix" exhaustive-deps by just adding the missing dep

STOP. Trace the dependency chain. Is everything stable?

Common Mistakes

MistakeFix
"ESLint said add it, so I did"Check if the dep is stable BEFORE adding
"It's just a small callback"Size doesn't matter, stability does
"The hook should handle this"Caller is responsible for stable refs

Dependency Chain Debugging

When something re-renders unexpectedly:

  1. Find the useMemo/useCallback that's recreating
  2. Check each dependency - which one changed?
  3. Trace that dependency back - why did IT change?
  4. Keep tracing until you find the unstable root
  5. Wrap the root in useCallback with stable deps

Real-World Impact

The bug: Quill editor threw addRange(): The given range isn't in document on every keystroke.

Root cause:

  1. ESLint fix changed useMemo deps from [toast] to [imageHandler]
  2. imageHandler depended on insertImage via useCallback
  3. insertImage was inline (new function every render)
  4. Chain: insertImageimageHandlermodules ↻ ReactQuill re-init

Fix: Wrap insertImage in useCallback with [] deps.

Time saved by knowing pattern: 2+ hours of debugging → 5 minutes.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.68%
按下载量换算76

Claude

31.61%
按下载量换算71

Cursor

18.71%
按下载量换算42

Gemini CLI

8.16%
按下载量换算18

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills