React component design
Skill Amey-Thakur/AI-SKILLS/skills/frontend/react-component-design
Plug-and-play skills and prompts for every AI coding agent
npx -y skills add Amey-Thakur/AI-SKILLS --skill react-component-designAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 19 days oldThe repository was created 19 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Design React component props and boundaries so components compose cleanly and stay reusable. Use when creating a component, reviewing a bloated props list, or deciding controlled versus uncontrolled.
SKILL.md
2.6 KB, as published. Nobody here has run it
React component design
A component is an API before it is markup. The props are the contract, and most component pain traces to a contract that configures behavior with flags instead of composing it with children.
Method
- Name the single responsibility first. A component does one thing: render a thing, own an interaction, or lay out other components. If you cannot state its job in one clause without "and", split it. Mixed responsibilities are the source of the twelve-prop component.
- Prefer composition over configuration. When a
variant,mode, orshowXprop starts branching the render tree, expose slots viachildrenor named render props instead. A<Card>that takes<Card.Header>and<Card.Body>scales; a<Card>withhasHeader,headerText,headerIcon,footerButtonsdoes not. - Decide controlled versus uncontrolled explicitly. Controlled means the
parent owns the value via
value+onChange; uncontrolled means the component owns it with an optionaldefaultValue. Pick one per piece of state and document it. Support both only through the standard pattern:value ?? internalValue. Silently switching between them mid-life is the React "controlled to uncontrolled" warning and a class of lost-edit bugs. - Keep the prop surface minimal and orthogonal. Every prop should be
independent; if two props are only valid in combination, model that as one
prop with a union type. Derive what you can from
childrenor context rather than asking for it. Fewer props means fewer illegal states. - Pass through the DOM props you did not consume. Spread
...restonto the root element and forwardrefwithforwardRefso callers can attacharia-*,className,onClick, and test ids without you enumerating them. A component that swallows unknown props forces a fork. - Default toward the common case. Set defaults so the zero-config usage is the right usage for most callers, and make the escape hatch explicit. Required props should be genuinely required, not defaulted to a guess.
Boundaries
- This is component API shape, not visual design; token and layout decisions belong to the design system.
- Global and server state placement is out of scope; see frontend-state.
- Framework primitives differ in Vue and Svelte, but composition-over-flags and explicit controlled state transfer directly.