The definitive guide to type-safe React state management, custom hooks, and reliable component patterns for large-scale applications.
# Modern React TypeScript Development
Master modern React development with TypeScript using Google Antigravity IDE. This comprehensive guide covers component patterns, hooks, and type-safe state management.
## Component Patterns
```typescript
// components/Button.tsx
import { forwardRef, ButtonHTMLAttributes, ReactNode } from "react";
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: "primary" | "secondary" | "ghost";
size?: "sm" | "md" | "lg";
loading?: boolean;
}
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
({ variant = "primary", size = "md", loading = false, className, ...props }, ref) => {
// Implementation
}
);
```
## Best Practices
- Use strict TypeScript configuration
- Apply proper generic constraints
- Create typed context with null checks
- Use discriminated unions for stateClick the copy button to get the raw system instruction optimized for token efficiency.
Paste directly into your IDE's agent instructions or global rules file.
Watch Gemini 3 adhere to strict architectural patterns without hallucination.