react

Guides React component authoring in LobeHub projects using base-ui, antd-style, and memoization conventions.

74|11|Updated Jul 4, 2024
One-click install
npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill react-opensourceagi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react
Source: https://github.com/OpenSourceAGI/qwksearch-research-agent/tree/main/apps/qwk-in-lobe/.agents/skills/react
Command: npx skills add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill react-opensourceagi

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Inconsistent component imports, styling approaches, and state management in LobeHub React codebases lead to duplicated UI primitives, unnecessary rerenders, and hard-to-maintain TSX files. ## Core Features & Use Cases - Component Selection Rules: Enforces a priority order from project components to @lobehub/ui/base-ui, @lobehub/ui, antd, and custom implementations, preventing accidental use of antd-backed root exports. - Styling Conventions: Directs use of createStaticStyles with cssVar for most cases, inline styles for one-offs, and createStyles only for truly dynamic values. - State and Performance Guidance: Defines when to extract hooks, split components, and apply memo, useMemo, or useCallback based on real rerender boundaries. - Use Case: When editing a settings panel TSX file, the Skill ensures you import Select and Modal from @lobehub/ui/base-ui, lay out sections with Flexbox, and avoid wrapping trivial components in memo. ## Quick Start Review my TSX component and fix the imports, styling, and memoization to follow the LobeHub React conventions.

Frequently Asked Questions about react

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

FAQPage Schema
How do I choose between @lobehub/ui base-ui and antd components?

Always prefer @lobehub/ui/base-ui when the component exists there, such as Select, Modal, Popover, or Drawer. Use @lobehub/ui root exports only when base-ui has no equivalent, and fall back to antd only when neither provides the component.

How should I style React components with antd-style in LobeHub?

Use createStaticStyles with cssVar tokens for most cases since it is zero-runtime and module-level. Use inline style attributes for simple one-offs, and reserve createStyles with token access for truly dynamic values like computed colors.

When should I use memo, useMemo, or useCallback in React?

Treat memoization as an opt-in optimization, not a default. First split at the update boundary, move state to its smallest owner, and narrow Zustand selectors; only memoize when the subtree is demonstrably expensive with stable inputs and a concrete render-path analysis.

Why is importing Select from @lobehub/ui root a mistake?

The root @lobehub/ui Select is the antd-backed version, not the headless base-ui primitive. The same applies to Modal, DropdownMenu, and similar components; import them from @lobehub/ui/base-ui instead.

How do I build layouts with Flexbox in @lobehub/ui?

Use the Flexbox and Center components from @lobehub/ui, preferring gap over margin for spacing and flex={1} to fill available space. Nest Flexbox for complex layouts and set overflow to auto for scrollable regions.