hooks
17
总安装量
17
周安装量
#20452
全站排名
安装命令
npx skills add https://github.com/elie222/inbox-zero --skill hooks
Agent 安装分布
amp
17
github-copilot
17
codex
17
kimi-cli
17
gemini-cli
17
cursor
17
Skill 文档
Custom Hook Guidelines
This rule outlines the guidelines for creating custom React hooks within this project.
Custom Hooks
- Purpose: Encapsulate reusable stateful logic, especially for data fetching or complex UI interactions.
- Location: Place custom hooks in the
apps/web/hooks/directory. - Naming: Use the
useprefix (e.g.,useAccounts.ts). - Data Fetching: For fetching data from API endpoints, prefer using
useSWR. Follow the guidelines outlined in data-fetching.mdc.- Create dedicated hooks for specific data types (e.g.,
useAccounts,useLabels). - The hook should typically wrap
useSWR, handle the API endpoint URL, and return the data, loading state, error state, and potentially themutatefunction from SWR.
- Create dedicated hooks for specific data types (e.g.,
- Simplicity: Keep hooks focused on a single responsibility.
By adhering to these guidelines, we ensure a consistent approach to reusable logic and data fetching throughout the application.