askill
react-best-practices

react-best-practicesSafety 90Repository

Apply React best practices for performance, correctness, and maintainability. Use when building or reviewing React applications.

0 stars
1.2k downloads
Updated 2/22/2026

Package Files

Loading files...
SKILL.md

React Best Practices

Critical: Eliminate Waterfalls

The most impactful performance issue. Never chain sequential async operations.

// Waterfall: B starts only after A finishes
const user = await getUser(id);
const posts = await getPosts(user.id);

// Parallel: both start simultaneously
const [user, posts] = await Promise.all([getUser(id), getPosts(id)]);

Component Design

State Management

// Derive state from existing state — don't duplicate
const filteredItems = useMemo(() => items.filter(i => i.active), [items]);

// Syncing state — avoid this
const [filteredItems, setFilteredItems] = useState([]);
useEffect(() => setFilteredItems(items.filter(i => i.active)), [items]);

Avoid Unnecessary Re-renders

// Memoize expensive components
const ExpensiveList = memo(({ items }: { items: Item[] }) => <List items={items} />);

// Stable references for callbacks
const handleClick = useCallback(() => doSomething(id), [id]);

// Memoize expensive calculations
const total = useMemo(() => items.reduce((sum, i) => sum + i.price, 0), [items]);

Component Composition

// Prefer composition over prop drilling
function Card({ children, header }: { children: React.ReactNode; header: React.ReactNode }) {
  return <div className="card"><div className="header">{header}</div>{children}</div>;
}

// Prop drilling through 3+ levels — use composition or context

Bundle Size

// Direct imports (treeshakeable)
import { format } from 'date-fns/format';

// Barrel imports (includes entire library) — avoid
import { format } from 'date-fns';

// Dynamic import for heavy components
const Chart = dynamic(() => import('./Chart'), { ssr: false });

Error Boundaries

// Every route/major section should have an error boundary
<ErrorBoundary fallback={<ErrorPage />}>
  <UserDashboard />
</ErrorBoundary>

TypeScript

// Explicit prop types
interface ButtonProps {
  label: string;
  onClick: () => void;
  variant?: 'primary' | 'secondary';
}

// any props — avoid
function Button(props: any) { ... }

Checklist

  • No sequential awaits that could be parallel
  • No useEffect for derived state
  • Expensive components wrapped in memo()
  • No barrel imports for large libraries
  • Error boundaries at route level
  • All props typed (no any)
  • Keys on all list items (not index)

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

85/100Analyzed 2/24/2026

High-quality technical reference covering critical React best practices including eliminating waterfalls, component design, bundle optimization, error boundaries, and TypeScript. Well-structured with clear code examples showing good vs bad patterns, plus a practical checklist. Penalized slightly for deep nesting in path suggesting internal project structure, but content itself is broadly reusable. Missing some topics like testing, accessibility, and state machines but covers the most impactful areas well.

90
85
80
75
85

Metadata

Licenseunknown
Version-
Updated2/22/2026
PublisherMartinNevlaha

Tags

No tags yet.