react-best-practices

Guide React component best practices for hooks, effects, and refs.

Updated Dec 26, 2025
One-click install
npx skills add https://github.com/Yoriichi-Dang/dashboard_web_template --skill react-best-practices-yoriichi-dang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-best-practices
Source: https://github.com/Yoriichi-Dang/dashboard_web_template/tree/main/.agents/skills/react-best-practices
Command: npx skills add https://github.com/Yoriichi-Dang/dashboard_web_template --skill react-best-practices-yoriichi-dang

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill consolidates React best practices to help developers write safer, more maintainable components by avoiding common pitfalls in hooks, effects, and rendering logic.

Core Features & Use Cases

  • Guidance on using effects correctly: when to apply useEffect vs rendering logic, and patterns for cleanup and dependencies.
  • Patterns for props and state management: controlled vs uncontrolled, composition over propagation, and memoization strategies.
  • Practical examples: escaping anti-patterns in common components like forms, lists, and data fetches.

Quick Start

Provide a quick assessment of a React component file, identify anti-patterns, and suggest a refactor plan.

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 useEffect vs render-time calculations in React?

Use useEffect only for synchronizing with external systems, while render-time calculations handle derived state and data transformations. Avoid unnecessary effects by computing values directly during render to ensure safe, maintainable React components.

How do I write safe cleanup functions for React effects?

Safe React effects require proper cleanup to prevent memory leaks and race conditions. Return a cleanup function from useEffect to cancel subscriptions, abort fetches, or reset timers, ensuring proper effect cleanup and maintainable component design.

What is the best way to manage controlled vs uncontrolled props in React components?

The best way to manage React props is choosing controlled components for predictable state synchronization and uncontrolled components for isolated internal state. Prefer composition over propagation to build clean, maintainable component designs.

Why does my React component re-render unnecessarily and how do I fix it?

React components re-render unnecessarily from misplaced state or missing memoization. Fix this by using memoization where appropriate, preferring render-time calculations over state updates, and avoiding unnecessary effects to ensure safe, maintainable code.

Can I use these React best practices for refactoring existing .tsx and .jsx files?

Yes, you can apply these React best practices to reading and writing existing .tsx and .jsx files. The Skill assesses your components, identifies anti-patterns in forms and lists, and suggests a refactor plan for clean component design.

How do I avoid common anti-patterns when fetching data in React components?

To avoid data fetch anti-patterns in React, apply effects correctly by managing dependencies and ensuring proper cleanup. Use memoization where appropriate and prefer composition over propagation to maintain safe, maintainable code.