用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/autohandai/community-skills --skill react-component-architecture命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Build, convert, validate, and install Autohand extensions, including Pi adaptations.
Run Weizhena's Deep Research workflow in Autohand Code for outline generation, deep web investigation, structured evidence capture, and final research reports.
Use Aaronontheweb dotnet-skills for Claude Code-oriented .NET maintenance, refactoring, and agent workflows.
基于 SOC 职业分类
正在显示 SKILL.md
| name | react-component-architecture |
| description | Modern React component patterns with hooks, composition, and TypeScript |
| license | MIT |
| compatibility | react 18+, typescript 5+ |
| allowed-tools | read_file write_file apply_patch search_with_context |
For complex UI with shared state:
const Tabs = ({ children, defaultValue }: TabsProps) => {
const [active, setActive] = useState(defaultValue);
return (
<TabsContext.Provider value={{ active, setActive }}>
{children}
</TabsContext.Provider>
);
};
Tabs.List = TabsList;
Tabs.Trigger = TabsTrigger;
Tabs.Content = TabsContent;
When consumers need control over rendering:
interface ListProps<T> {
items: T[];
renderItem: (item: T, index: number) => ReactNode;
keyExtractor: (item: T) => string;
}
function List<T>({ items, renderItem, keyExtractor }: ListProps<T>) {
return items.map((item, i) => (
<Fragment key={keyExtractor(item)}>{renderItem(item, i)}</Fragment>
));
}
Extract reusable stateful logic:
function useToggle(initial = false) {
const [state, setState] = useState(initial);
const toggle = useCallback(() => setState(s => !s), []);
const setTrue = useCallback(() => setState(true), []);
const setFalse = useCallback(() => setState(false), []);
return { state, toggle, setTrue, setFalse } as const;
}
Components that render as different elements:
type PolymorphicProps<E extends ElementType> = {
as?: E;
} & ComponentPropsWithoutRef<E>;
function Box<E extends ElementType = 'div'>({
as,
...props
}: PolymorphicProps<E>) {
const Component = as || 'div';
return <Component {...props} />;
}
For mutually exclusive prop combinations:
type ButtonProps =
| { variant: 'link'; href: string; onClick?: never }
| { variant: 'button'; onClick: () => void; href?: never };
function Button({
variant = 'primary',
size = 'md',
...props
}: ButtonProps) {
// ...
}
useMemouseCallbackReact.memo for pure presentational componentscomponents/
Button/
Button.tsx # Component
Button.test.tsx # Tests
Button.types.ts # Types (if complex)
index.ts # Re-export