react-frontend
БесплатноЗапускает вложенные скриптыНе проверенReact frontend standards covering hooks (useState, useEffect, useContext, custom hooks), state management (Context API, Redux, Zustand), performance…
Об этом скилле
React Frontend Development Standards
Quick Reference
Essential Hooks
// State Hook
const [count, setCount] = useState(0);
const [user, setUser] = useState<User | null>(null);
// Effect Hook
useEffect(() => {
// Side effect
return () => {/* cleanup */};
}, [dependencies]);
// Context Hook
const theme = useContext(ThemeContext);
// Ref Hook
const inputRef = useRef<HTMLInputElement>(null);
// Memo Hooks
const value = useMemo(() => expensiveCalc(a, b), [a, b]);
const callback = useCallback(() => doSomething(a), [a]);
State Management Decision Tree
Is state needed in >2 components?
NO -> Use local state (useState)
YES -> Is it global UI state (theme, auth)?
YES -> Use Context API
NO -> Is it server data (API responses)?
YES -> Use React Query/TanStack Query
NO -> Complex state with many actions?
YES -> Use Redux Toolkit or Zustand
NO -> Use Context API + useReducer
Component Checklist
- Use functional components with hooks
- Destructure props with TypeScript types
- Use semantic HTML elements
- Add proper ARIA labels where needed
- Memoize expensive computations with useMemo
- Memoize callbacks passed to children with useCallback
- Add loading and error states
- Clean up effects with return function
- Keep components under 300 lines
Performance Checklist
- Use React.lazy() for code splitting
- Wrap expensive components in React.memo()
- Implement virtual scrolling for long lists
- Lazy load images with loading="lazy"
- Avoid inline object/array creation in JSX
Quick Start
# Create React app with TypeScript
npx create-react-app my-app --template typescript
# Install testing library
npm install --save-dev @testing-library/react @testing-library/jest-dom
# Install React Query for server state
npm install @tanstack/react-query
# State management (choose one)
npm install zustand # Lightweight
npm install @reduxjs/toolkit # Enterprise
Core Hooks Patterns
useState
// Lazy initialization for expensive initial state
const [data, setData] = useState(() => computeExpensiveValue());
// Functional updates when new state depends on old
setCount(prevCount => prevCount + 1);
useEffect
// Component mount (runs once)
useEffect(() => {
console.log('Component mounted');
}, []);
// Cleanup pattern for async operations
useEffect(() => {
let isMounted = true;
async function fetchData() {
const result = await api.getData();
if (isMounted) setData(result);
}
fetchData();
return () => { isMounted = false; };
}, []);
// Subscription cleanup
useEffect(() => {
const subscription = api.subscribe(userId);
return () => subscription.unsubscribe();
}, [userId]);
useContext
// Create context with TypeScript
interface ThemeContextType {
theme: 'light' | 'dark';
toggleTheme: () => void;
}
const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
// Custom hook for consuming context (always use this pattern)
export const useTheme = () => {
const context = useContext(ThemeContext);
if (!context) throw new Error('useTheme must be used within ThemeProvider');
return context;
};
useReducer
type Action = { type: 'increment' } | { type: 'decrement' } | { type: 'reset' };
function reducer(state: State, action: Action): State {
switch (action.type) {
case 'increment': return { count: state.count + 1 };
case 'decrement': return { count: state.count - 1 };
case 'reset': return { count: 0 };
default: return state;
}
}
const [state, dispatch] = useReducer(reducer, { count: 0 });
Custom Hooks
// Always prefix with 'use'
function useFetch<T>(url: string) {
const [data, setData] = useState<T | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
useEffect(() => {
let isMounted = true;
fetch(url)
.then(res => res.json())
.then(data => { if (isMounted) { setData(data); setLoading(false); }})
.catch(err => { if (isMounted) { setError(err); setLoading(false); }});
return () => { isMounted = false; };
}, [url]);
return { data, loading, error };
}
State Management
Context API (Theme, Auth, Locale)
// Split contexts to reduce re-renders
<AuthProvider>
<ThemeProvider>
<LocaleProvider>
<App />
</LocaleProvider>
</ThemeProvider>
</AuthProvider>
React Query (Server State)
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
function Users() {
const { data, isLoading } = useQuery({
queryKey: ['users'],
queryFn: fetchUsers,
});
const queryClient = useQueryClient();
const mutation = useMutation({
mutationFn: createUser,
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['users'] }),
});
}
Установить react-frontend в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл react-frontend?
React frontend standards covering hooks (useState, useEffect, useContext, custom hooks), state management (Context API, Redux, Zustand), performance optimization (memoization, lazy loading, code splitting), testing with React Testing Library, and accessibility (WCAG 2.1, ARIA) for modern SPAs
Как установить скилл react-frontend?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл react-frontend запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic