> 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)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/react-typescript?format=md"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);
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)