react
$
npx mdskill add partme-ai/full-stack-skills/reactGuides React development for building components, managing state, optimizing performance, and implementing best practices.
- Helps developers create user interfaces and manage application logic in React projects.
- Integrates with tools like Vite, Create React App, React Router, and state libraries.
- Follows official documentation patterns to apply React best practices and verify code.
- Delivers results by generating JSX/TSX code and providing step-by-step guidance.
SKILL.md
.github/skills/reactView on GitHub ↗
---
name: react
description: "Provides comprehensive guidance for React development including components, JSX, props, state, hooks, context, performance optimization, and best practices. Use when the user asks about React, needs to create React components, implement hooks, manage component state, or build React applications."
license: Complete terms in LICENSE.txt
---
## When to use this skill
Use this skill whenever the user wants to:
- Build user interfaces with React components and JSX
- Manage component state and lifecycle with hooks
- Create reusable, composable React components
- Use Context API or state management libraries (Redux, Zustand)
- Set up React projects with Vite or Create React App
- Implement routing with React Router
- Optimize rendering performance (React.memo, useMemo, lazy loading)
## How to use this skill
### Workflow
1. **Identify the request area** (component creation, state management, routing, performance, etc.)
2. **Apply React best practices** following the official documentation patterns
3. **Generate JSX/TSX code** using functional components and hooks
4. **Verify** the component tree renders correctly and state flows are clean
### 1. Functional Component
```tsx
import { useState } from 'react';
interface UserCardProps {
name: string;
email: string;
onSelect: (name: string) => void;
}
export function UserCard({ name, email, onSelect }: UserCardProps) {
return (
<div className="user-card" onClick={() => onSelect(name)}>
<h3>{name}</h3>
<p>{email}</p>
</div>
);
}
```
### 2. State and Effects
```tsx
import { useState, useEffect } from 'react';
export function UserList() {
const [users, setUsers] = useState<User[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
fetch('/api/users')
.then(res => res.json())
.then(data => {
setUsers(data);
setLoading(false);
});
}, []);
if (loading) return <p>Loading...</p>;
return (
<ul>
{users.map(user => (
<li key={user.id}>{user.name}</li>
))}
</ul>
);
}
```
### 3. Custom Hook
```tsx
import { useState, useCallback } from 'react';
function useToggle(initial = false): [boolean, () => void] {
const [value, setValue] = useState(initial);
const toggle = useCallback(() => setValue(v => !v), []);
return [value, toggle];
}
```
### 4. Context Pattern
```tsx
import { createContext, useContext, useState, ReactNode } from 'react';
const ThemeContext = createContext<{ dark: boolean; toggle: () => void } | null>(null);
export function ThemeProvider({ children }: { children: ReactNode }) {
const [dark, setDark] = useState(false);
const toggle = () => setDark(d => !d);
return <ThemeContext.Provider value={{ dark, toggle }}>{children}</ThemeContext.Provider>;
}
export function useTheme() {
const ctx = useContext(ThemeContext);
if (!ctx) throw new Error('useTheme must be used within ThemeProvider');
return ctx;
}
```
## Best Practices
- Keep components small and focused on a single responsibility
- Lift state up to the nearest common ancestor; use Context for deeply shared state
- Always provide a stable `key` prop when rendering lists
- Clean up side effects in `useEffect` return functions (subscriptions, timers)
- Avoid creating new objects/functions inline in JSX to prevent unnecessary re-renders
- Use `React.lazy` and `Suspense` for code-splitting large routes
## Resources
- Official documentation: https://react.dev/
- React hooks reference: https://react.dev/reference/react
- Create React App: https://create-react-app.dev/
## Keywords
react, React Hooks, JSX, TSX, components, state, props, useEffect, useState, Context API, functional components, performance, memo, lazy loading
More from partme-ai/full-stack-skills
- adobe-xd"Guides creation of UI/UX designs, interactive prototypes, reusable components, and design specs in Adobe XD. Use when the user asks about Adobe XD artboards, prototype links, repeat grids, component states, design tokens export, or developer handoff."
- angular"Provides comprehensive guidance for Angular framework including components, modules, services, dependency injection, routing, forms, and TypeScript integration. Use when the user asks about Angular, needs to create Angular applications, implement Angular components, or work with Angular features."
- ansible"Provides comprehensive guidance for Ansible automation including playbooks, roles, inventory, and module usage. Use when the user asks about Ansible, needs to automate IT tasks, create Ansible playbooks, or manage infrastructure with Ansible."
- ant-design-mini"Builds mini-program UIs with Ant Design Mini components for Alipay and WeChat mini-programs. Covers Button, Form, List, Modal, Tabs, NavBar, and 60+ components with theme customization and CSS variable theming. Use when the user needs to create mini-program interfaces with Ant Design Mini, configure themes, or implement mini-program-specific UI patterns."
- ant-design-mobile"Builds React mobile UIs with Ant Design Mobile (antd-mobile) components including Button, Form, List, Modal, Picker, Tabs, PullToRefresh, InfiniteScroll, and 50+ mobile-optimized components. Use when the user needs to create mobile-first React interfaces, implement mobile navigation, forms, or data display with Ant Design Mobile."
- ant-design-react"Builds enterprise React UIs with Ant Design (antd) including 60+ components (Button, Form, Table, Select, Modal, Message), design tokens, TypeScript support, and ConfigProvider theming. Use when the user needs to create React applications with Ant Design, build forms with validation, display data tables, or customize the Ant Design theme."
- ant-design-vueProvides comprehensive guidance for Ant Design Vue (AntDV) component library for Vue 3. Covers installation, usage, API reference, templates, and all component categories. Use when building enterprise-class UI with Vue 3 and Ant Design.
- api-doc-generator"Generate API documentation by scanning Controller classes, extracting endpoint URLs, HTTP methods, parameters, and response structures, then producing standardized docs from templates. Use when the user explicitly mentions generating API documentation, creating API docs, scanning interfaces, or documenting REST APIs. Do not trigger for generic documentation requests without explicit API mention."
- appium"Provides comprehensive guidance for Appium mobile testing including mobile app automation, element location, gestures, and cross-platform testing. Use when the user asks about Appium, needs to test mobile applications, automate mobile apps, or write Appium test scripts."
- ascii-ansi-colorizer"Add an ANSI color layer to existing ASCII/plain-text output (gradient/rainbow/highlights) with alignment-safe rules and a required no-color fallback. Use when the user wants to colorize terminal output, add rainbow effects to CLI text, or style ASCII art with ANSI colors."