react-best-practices

Optimize React 18 and Vite frontend development with official best practices.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/magisph/rv-adv --skill react-best-practices-magisph
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-best-practices
Source: https://github.com/magisph/rv-adv/tree/main/.agent/skills/react-best-practices
Command: npx skills add https://github.com/magisph/rv-adv --skill react-best-practices-magisph

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers write more efficient and robust React components by adhering to best practices, preventing common issues like memory leaks and stale closures.

Core Features & Use Cases

  • Memory Leak Prevention: Guides on using useEffect cleanup functions.
  • State Management: Advises on managing dependencies in useCallback and useMemo to avoid stale closures.
  • User Experience: Emphasizes implementing loading and error states for better UX feedback.
  • Use Case: When refactoring a complex React component, use this Skill to ensure all effects are properly cleaned up and state updates are handled efficiently.

Quick Start

Apply the react-best-practices skill to the new UserProfile.jsx component.

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 memory leaks in React useEffect hooks?

Avoid stale closures in React by correctly specifying all referenced state and props within the dependency arrays of useCallback and useMemo, ensuring the callbacks always access current values.

What is the best way to optimize React 18 component performance?

Optimize React 18 component performance by managing useCallback and useMemo dependencies, applying useEffect cleanup functions, and implementing loading and error states for efficient UX feedback.

How do I avoid stale closures with useCallback and useMemo?

Avoid stale closures in React by correctly specifying all referenced state and props within the dependency arrays of useCallback and useMemo, ensuring the callbacks always access current values.

Does this React optimization guidance work with Vite?

Prevent memory leaks in React useEffect by implementing cleanup functions that cancel subscriptions, clear timers, and abort fetch requests when the component unmounts or dependencies change.

Why should I implement loading and error states in React components?

Avoid stale closures in React by correctly specifying all referenced state and props within the dependency arrays of useCallback and useMemo, ensuring the callbacks always access current values.