react

Provide React development best practices for hooks, components, state, and performance.

1|Updated Nov 3, 2024
One-click install
npx skills add https://github.com/kingstinct/.github --skill react-kingstinct
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react
Source: https://github.com/kingstinct/.github/tree/main/react/skills/react
Command: npx skills add https://github.com/kingstinct/.github --skill react-kingstinct

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides comprehensive guidelines and best practices for writing maintainable, performant, and scalable React applications, helping developers avoid common pitfalls and improve code quality.

Core Features & Use Cases

  • Hook Design Principles: Guidance on creating lean, focused, and composable hooks.
  • Component Patterns: Best practices for small, reusable components, functional components, and prop naming.
  • State Management: Strategies for colocating state, deriving state, and choosing between Context and external libraries.
  • Performance Optimization: Advice on using memo, useMemo, useCallback, and understanding React Compiler's role.
  • Error Handling & Keys: Implementing error boundaries and using stable, unique keys.
  • Use Case: A developer is unsure about the best way to manage shared state in a complex React app. They can consult this Skill for recommendations on using external state libraries over Context for frequently updating state, and learn how to structure their hooks and components for optimal performance.

Quick Start

Consult the React Guidelines to understand how to structure your custom hooks for better reusability and maintainability.

Frequently Asked Questions about react

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

FAQPage Schema
What's the best way to structure custom hooks for React performance optimization?

To optimize React performance, structure custom hooks to be lean, focused, and composable. This approach ensures better state colocation, simplifies memoization strategies, and enhances overall component maintainability.

How do I manage shared state in a complex React app without causing re-renders?

Managing shared state in a complex React app requires colocating state appropriately and deriving state when possible. For frequently updating state, external state libraries are recommended over Context to prevent unnecessary component re-renders.

When should I use useMemo and useCallback in React components?

Use useMemo and useCallback in React components to optimize performance by memoizing expensive calculations and callback functions. These memoization strategies prevent unnecessary re-renders, especially when passing props to child components.

Does React Context work well for frequently updating state?

React Context is not ideal for frequently updating state because it can trigger widespread component re-renders. Choosing external state libraries over Context is recommended for managing high-frequency state changes in complex applications.

Why does React require stable and unique keys for list items?

React requires stable and unique keys for list items to accurately identify which elements have changed, been added, or removed. Proper key management ensures optimal rendering performance and prevents UI state bugs during reconciliation.