react-best-practices

Enforces React best practices for TypeScript and JavaScript components.

Updated Dec 7, 2025
One-click install
npx skills add https://github.com/MattRib/financial_app --skill react-best-practices-mattrib
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-best-practices
Source: https://github.com/MattRib/financial_app/tree/main/.agents/skills/react-best-practices
Command: npx skills add https://github.com/MattRib/financial_app --skill react-best-practices-mattrib

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

React codebases often suffer from inconsistent patterns around hooks, effects, and refs, leading to fragile components and hard-to-maintain state logic. This Skill provides practical guidelines to help teams write safer, more readable React components and avoid common anti-patterns.

Core Features & Use Cases

  • Effect usage guidance: When to use useEffect and how to avoid stale state and unnecessary renders.
  • Ref and event handling: Safe patterns for useRef, useImperativeHandle, and event handlers.
  • Custom hooks & composition: Favor focused hooks and composition over prop drilling to improve reuse.
  • Performance & maintenance: Use useMemo where appropriate, manage dependencies, and maintain predictable renders.
  • Onboarding & code review: Helps new contributors align with team conventions and improve review quality.

Quick Start

Audit a sample React component and refactor to follow the patterns described in this skill.

Frequently Asked Questions about react-best-practices

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

FAQPage Schema
How do I avoid stale state and unnecessary renders when using useEffect?

To avoid stale state in useEffect, ensure effect dependencies are correctly specified and manage state updates to prevent unnecessary renders. This Skill guides correct cleanup patterns and dependency array usage for safer React components.

When should I use useRef instead of state in React components?

Use useRef for mutable values that don't trigger re-renders, like accessing DOM elements or storing event handler references. This Skill provides safe patterns for using refs, useImperativeHandle, and event handlers in React.

What's the best way to structure React components and custom hooks for reuse?

The best way to structure React components is favoring focused custom hooks and composition over prop drilling. This Skill guides component design to improve reuse and maintain predictable renders in your codebase.

Does this React best practices guidance work with TypeScript projects?

Yes, this React best practices guidance applies to modern React projects using TypeScript or JavaScript. It enforces safe, maintainable component patterns for .tsx and .jsx files during development and code reviews.

How do I refactor a React component to follow best practices during code review?

Refactor React components by auditing effect usage, ref patterns, and memoization against established guidelines. This Skill helps contributors align with team conventions and improve review quality during onboarding and refactoring.

When should I not use useMemo for performance optimization in React?

You should not use useMemo unnecessarily when the computational cost of recalculating values is lower than the memory overhead. This Skill guides appropriate useMemo usage and dependency management to maintain predictable renders.