react-best-practices

Enforce React best practices for hooks, effects, and component patterns.

Updated Jan 9, 2026
One-click install
npx skills add https://github.com/SKANL/saas-abogados-nextjs --skill react-best-practices-skanl
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-best-practices
Source: https://github.com/SKANL/saas-abogados-nextjs/tree/main/.agents/skills/react-best-practices
Command: npx skills add https://github.com/SKANL/saas-abogados-nextjs --skill react-best-practices-skanl

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill consolidates React best practices to reduce bugs and anti-patterns in component code, providing a clear framework for writing and reviewing React components with confidence.

Core Features & Use Cases

  • Escape hatch principle: use Effects to synchronize with external systems, not for core logic.
  • When to use Effects: guidance on data fetching, subscriptions, event listeners, and external integrations.
  • Dependency discipline: proper use of dependency arrays, updater patterns, and avoiding stale closures.
  • useEffectEvent and callback stability: techniques to stabilize non-reactive logic and event handlers.
  • Custom hooks and component patterns: focused, reusable hooks; controlled vs. uncontrolled components; composition over prop drilling.
  • Anti-patterns to avoid: derived state during render, excessive effect chains, and recreating objects inside effects.

Quick Start

Review the core principle (effects as escape hatches) and apply the guidelines when writing or refactoring React components (.tsx/.jsx files with React imports). Pair this skill withtypescript-best-practices for TS projects, and progressively adopt the documented patterns in your codebase during code reviews and onboarding.

Frequently Asked Questions about react-best-practices

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

FAQPage Schema
When should I use React useEffect instead of regular event handlers?

Use React useEffect as an escape hatch to synchronize with external systems like data fetching, subscriptions, or event listeners, not for core component logic. Effects manage external integrations and cleanup, keeping reactive logic separate from rendering.

How do I avoid stale closures in React hooks dependency arrays?

Avoid stale closures in React hooks by maintaining strict dependency discipline, using updater patterns for state changes, and applying useEffectEvent to stabilize non-reactive logic. Proper dependency arrays ensure effects capture current values without recreating objects.

What are common React anti-patterns when managing derived state?

Common React anti-patterns include deriving state during render, chaining excessive effects, and recreating objects inside effects. These pitfalls cause unnecessary re-renders and bugs; use composition and focused custom hooks to avoid them.

How do I stabilize non-reactive event handlers in React components?

Stabilize non-reactive event handlers in React using useEffectEvent to isolate logic from reactive dependencies. This technique ensures callback stability across renders without adding variables to dependency arrays, preventing unnecessary effect executions.

Can I use these React patterns for refactoring existing .tsx components?

Yes, apply these React patterns when refactoring functional .tsx or .jsx components. The guidelines support everyday development tasks including building, reviewing, and refactoring component code to reduce bugs and enforce proper hooks, refs, and memoization usage.

What is the best way to structure custom hooks for React composition?

Structure custom hooks as focused, reusable functions to promote composition over prop drilling. This pattern enforces controlled versus uncontrolled component designs and ensures effects, refs, and memoization integrate cleanly without anti-patterns.