component-refactoring

Refactor high-complexity React components in the Dify frontend by extracting hooks and sub-components.

Updated Jan 9, 2026
One-click install
npx skills add https://github.com/mr-phariyawit/startup --skill component-refactoring-mr-phariyawit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: component-refactoring
Source: https://github.com/mr-phariyawit/startup/tree/main/.agent/skills/component-refactoring
Command: npx skills add https://github.com/mr-phariyawit/startup --skill component-refactoring-mr-phariyawit

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Refactor high-complexity React components in the Dify frontend to reduce cognitive load and improve maintainability.

Core Features & Use Cases

  • Extract custom hooks for related state and effects to simplify components.
  • Split large components into focused sub-components and modules.
  • Centralize modal, form, and API logic to improve reuse and testing.
  • Apply standardized patterns like hooks, panels, and data layer separation across web/app directories.

Quick Start

Refactor one high-complexity component at a time by extracting a single piece (hook, sub-component, or modal) and iteratively running linting, type-checking, and tests after each step.

Frequently Asked Questions about component-refactoring

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

FAQPage Schema
How do I refactor high-complexity React components to reduce cognitive load?

To refactor high-complexity React components, extract custom hooks for related state and split large components into focused sub-components. This reduces cognitive load by centralizing modal, form, and API logic for improved reuse and maintainability.

What is the best way to split a large React component with nested conditional logic?

The best way to split a large React component is to apply standardized patterns like component extraction and hook extraction. Break down components with nested conditional logic into focused sub-components and modules iteratively.

How do I extract custom hooks from a complex React component?

Extract custom hooks by identifying related state and effects within a complex React component and moving them into dedicated hook functions. This simplifies the main component and centralizes logic for better testing and reuse.

When should I separate API and data handling logic in React components?

Separate API and data handling logic in React components when complexity thresholds or long line counts are exceeded. Centralizing API logic improves reuse and testing across web and app directories.

Can I refactor a complex React component incrementally without breaking existing tests?

Yes, you can refactor incrementally by extracting a single piece like a hook, sub-component, or modal at a time. Run linting, type-checking, and tests after each step to ensure changes follow standardized patterns without breaking functionality.

Does this React refactoring approach apply to both web and app directories?

Yes, this React refactoring approach applies standardized patterns like hook extraction, component splitting, and API separation across both web and app directories. It ensures consistent maintainability improvements throughout the entire frontend.