name: React TypeScript description: TypeScript patterns specific to React components and hooks. metadata: labels: [react, typescript, types] triggers: files: ['**/*.tsx'] keywords: [ReactNode, FC, PropsWithChildren, ComponentProps]
React TypeScript
Priority: P1 (OPERATIONAL)
Type-safe React patterns.
Implementation Guidelines
-
Components: Return
JSX.Element. Props interface overReact.FC. -
Children: Use
ReactNodeorPropsWithChildren<T>. -
Events:
React.ChangeEvent<HTMLInputElement>. -
Hooks:
useRef<HTMLDivElement>(null).useState<User | null>(null). -
Props: Use
ComponentProps<'button'>to mirror native els. -
Generics:
<T,>(props: ListProps<T>). -
Polymorphism:
asprop patterns.
Anti-Patterns
-
No
any: Useunknown. -
No
React.FC: Implicit children is deprecated/bad practice. -
No
Function: Use(args: T) => void.
Code
// Modern Props
type ButtonProps = ComponentProps<'button'> & {
variant?: 'primary' | 'secondary';
};
// Generic Component
type ListProps<T> = {
items: T[];
render: (item: T) => ReactNode;
};
function List<T>({ items, render }: ListProps<T>) {
return <ul>{items.map(render)}</ul>;
}
// Hook Ref
const inputRef = useRef<HTMLInputElement>(null);
chat Comments (0)
Sign in to join the discussion and leave a comment.
Skill Details
GitHub Stars
143
GitHub Forks
48
Created
Jan 2026
Last Updated
il y a 8 mois
tools
tools frontend
Related Skills
Build your own?
Join 12,000+ developers contributing to the Claude ecosystem.
No comments yet. Be the first to share your thoughts!