react-dev_skill

This skill helps you build type-safe React components with TypeScript, including hooks, events, and server routing integrations.
  • Python

273

GitHub Stars

2

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill softaworks/agent-toolkit --skill react-dev

  • README.md12.9 KB
  • SKILL.md10.0 KB

Overview

This skill provides practical, type-safe patterns for building React components with TypeScript, covering React 18 and React 19 features. It focuses on correct typing for props, events, hooks, generic components, Server Components, and router integration. Use it to eliminate runtime type errors and enable confident refactoring.

How this skill works

The skill inspects component and hook patterns and offers concrete TypeScript typings and code templates. It enforces explicit useState/useRef typing, specific React event types, discriminated unions for variants, and React 19 conventions like ref-as-prop, useActionState, and use(). It also includes typed examples for TanStack Router and React Router v7 loaders and actions.

When to use it

  • Building new React components in TypeScript
  • Implementing generic or constrained components (tables, lists, selects)
  • Typing event handlers, forms, refs, and custom hooks
  • Migrating to React 19 features (use(), useActionState, ref as prop)
  • Integrating type-safe routing with TanStack Router or React Router v7

Best practices

  • Always use specific React event types (MouseEvent, ChangeEvent, FormEvent) instead of any
  • Annotate useState for unions or nullable state (e.g., User | null)
  • Extend native elements with ComponentPropsWithoutRef for accurate props and intrinsic attributes
  • Use discriminated unions for variant props and guarded switches for exhaustive handling
  • Return tuples with as const for custom hooks that expose stable tuples
  • Follow React 19 rules: ref passed as a prop, avoid forwardRef, useActionState for form actions, and use() to unwrap promises

Example use cases

  • Type-safe Button that extends native button props and supports variants with discriminated unions
  • Generic Table<T> component using keyof T and render props that infers column types from data
  • Typed form with useActionState for server actions and precise FormEvent handling
  • Server Component page that passes a promise to a client component and uses use() on the client to unwrap it
  • Router integration showing typed loaders and validated search params with TanStack Router or React Router v7

FAQ

No. In React 19, prefer passing ref as a regular prop typed as React.Ref<T>. Avoid forwardRef for new components.

How should I type DOM refs?

Use useRef<HTMLInputElement | null>(null) for DOM refs and guard with optional chaining or null checks before access.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
react-dev skill by softaworks/agent-toolkit | VeilStrat