react-typescript
TypeScript patterns specific to React components and hooks.
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
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);
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!