Skip to content
Back to skills

React Typescript

ASecurity

React + TypeScript patterns for production frontends. Use when building React components, hooks, state management, forms, routing, or any React/TSX UI.

  • 108 stars
  • 0 votes
  • 7 copies
  • 104 views
  • Added September 7, 2026
developmenttypescriptgoreactapifrontend

Works with

  • cli
  • api

Security analysis

A100/100

Scanned September 7, 2026

npx -y skills add cohen-liel/hivemind --skill react-typescript --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of React Typescript?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for React Typescript
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/cohen-liel-react-typescript/badge)](https://www.skillsdirectory.com/skills/cohen-liel-react-typescript)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: react-typescript
description: React + TypeScript patterns for production frontends. Use when building React components, hooks, state management, forms, routing, or any React/TSX UI.
---

# React + TypeScript Patterns

## Project Structure
```
src/
  components/     # Reusable UI components
  pages/          # Route-level components
  hooks/          # Custom hooks (useAuth, useApi, etc.)
  store/          # Zustand/Redux state
  api/            # API client functions (axios/fetch wrappers)
  types/          # Shared TypeScript types/interfaces
  utils/          # Pure utility functions
```

## Component Pattern
```tsx
interface ButtonProps {
  label: string
  onClick: () => void
  variant?: 'primary' | 'secondary' | 'danger'
  disabled?: boolean
  isLoading?: boolean
}

export const Button: React.FC<ButtonProps> = ({
  label, onClick, variant = 'primary', disabled, isLoading
}) => {
  return (
    <button
      onClick={onClick}
      disabled={disabled || isLoading}
      className={`btn btn-${variant}`}
    >
      {isLoading ? <Spinner /> : label}
    </button>
  )
}
```

## Custom Hook Pattern
```tsx
function useApi<T>(url: string) {
  const [data, setData] = useState<T | null>(null)
  const [loading, setLoading] = useState(true)
  const [error, setError] = useState<string | null>(null)

  useEffect(() => {
    const controller = new AbortController()
    fetch(url, { signal: controller.signal })
      .then(r => r.json())
      .then(setData)
      .catch(e => { if (e.name !== 'AbortError') setError(e.message) })
      .finally(() => setLoading(false))
    return () => controller.abort()
  }, [url])

  return { data, loading, error }
}
```

## State Management (Zustand)
```tsx
interface AuthStore {
  user: User | null
  token: string | null
  login: (user: User, token: string) => void
  logout: () => void
}

const useAuthStore = create<AuthStore>((set) => ({
  user: null,
  token: null,
  login: (user, token) => set({ user, token }),
  logout: () => set({ user: null, token: null }),
}))
```

## Form Pattern (React Hook Form)
```tsx
const { register, handleSubmit, formState: { errors } } = useForm<FormData>({
  resolver: zodResolver(schema)
})
```

## Rules
- Always type props explicitly — no `any`
- Use `React.FC<Props>` for components
- Cleanup effects: return cleanup function from useEffect
- Memoize expensive computations with useMemo
- Memoize callbacks passed to children with useCallback
- Split large components: <300 lines per file
- Error boundaries around page-level components
- Lazy load routes: `const Page = React.lazy(() => import('./Page'))`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.