react-best-practices

Enforces React and Next.js performance patterns for rendering, hooks, and component architecture.

1|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/TarunTeja44/portfolio --skill react-best-practices-tarunteja44
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-best-practices
Source: https://github.com/TarunTeja44/portfolio/tree/main/.agents/skills/react-best-practices
Command: npx skills add https://github.com/TarunTeja44/portfolio --skill react-best-practices-tarunteja44

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? React and Next.js applications often suffer from unnecessary re-render cascades, misused hooks, and poorly placed state, leading to sluggish UIs and hard-to-maintain code. This Skill provides concrete rules and reference guides to write performant, well-architected React code from the start. ## Core Features & Use Cases - Rendering Optimization: Prevents re-render cascades through state colocation, component composition with children, context splitting, and correct key prop usage. - Hook Usage Rules: Defines when to use useMemo, useCallback, useRef, and useTransition, and when to avoid unnecessary useEffect for derived state or event logic. - Next.js Architecture Guidance: Covers Server vs Client Component boundaries, Suspense streaming, and keeping client boundaries at leaf nodes. - Use Case: When reviewing a dashboard page where typing in a search input re-renders heavy charts, apply the composition pattern to isolate state and stop the cascade. ## Quick Start Review my React component for unnecessary re-renders and suggest fixes based on React and Next.js best practices.

Frequently Asked Questions about react-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent unnecessary re-renders in React?

Prevent re-renders by colocating state near its consumers, using children composition to isolate stateful wrappers from heavy subtrees, and avoiding new object or function references passed to memoized children. Profile with React DevTools to confirm the fix.

When should I use useMemo and useCallback in React?

Use useMemo only for expensive calculations like sorting large lists, and useCallback for functions passed to memoized children or hook dependency arrays. Wrapping cheap computations or every handler adds overhead without benefit.

Should I use Server Components or Client Components in Next.js?

Use Server Components by default for data fetching and static content since they add zero bundle overhead and keep secrets on the server. Add 'use client' only at leaf nodes that need interactivity like onClick handlers, inputs, or browser APIs.

Why is using array index as key bad in React lists?

Using array index as key breaks React's reconciliation when lists are reordered, filtered, or sorted, causing incorrect state association and rendering bugs. Always use stable unique identifiers like item.id for dynamic lists.

When should I avoid useEffect in React?

Avoid useEffect for derived state, which should be computed during render or with useMemo, and for user event logic, which belongs directly in event handlers like onClick or onSubmit. Reserve useEffect for genuine external system synchronization.