React typescript
Skill ComeOnOliver/skillshub/skills/HoangNguyen0403/agent-skills-standard/react-typescript
TypeScript patterns specific to React components and hooks. Use when typing React props, hooks, event handlers, or component generics in TypeScript. (triggers: **/*.tsx, ReactNode, FC, PropsWithChildren, ComponentProps)From its SKILL.md
npx -y skills add ComeOnOliver/skillshub --skill react-typescriptAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.7 KB, 382 tokens by cl100k_base, as published. Nobody here has run it
React TypeScript
Priority: P1 (OPERATIONAL)
Type-safe React patterns.
Implementation Guidelines
- Components: Prefer interface/type (
Props) overReact.FC(which has implicit children). UseJSX.ElementorReactNodeas the return type. - Children: For components that accept children, use
PropsWithChildren<T>or explicitly type them asReact.ReactNode. - Events: Always type event handlers using specific React events, such as
React.ChangeEvent<HTMLInputElement>orReact.FormEvent<HTMLFormElement>. - Hooks: For
useRef, avoidany; useuseRef<HTMLDivElement>(null). ForuseState, use generics for complex types:useState<User | null>(null). - Native Elements: Use
ComponentPropsWithoutRef<'button'>orComponentPropsWithRefto extend native attributes safely. - Generics: Implement generic components for reusable UI like lists using
<T,>(props: ListProps<T>). - Discriminated Unions: Use Discriminated Unions for mutually exclusive props (e.g.,
successvserrorstates). - Utility Types: Leverage
Omit,Pick, andPartialto transform prop interfaces and avoid redundancy.
Anti-Patterns
- No
any: Useunknown. - No
React.FC: Implicit children is deprecated/bad practice. - No
Function: Use(args: T) => void.
References
See references/example.md for typed props, generic components, and hook ref patterns.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.