React

Structure a React Component

Structure a React component by deciding its responsibility, naming props clearly, keeping state close to where it is used and separating reusable UI from page-specific content.

What this workflow solves

Target outcome

A React component that is easier to reuse, test, style and connect to real product workflows.

Work through React component

Track each step, focus the current task and copy a starter outline for your project notes or implementation plan.

0% complete
Define the component responsibility

A component is easier to maintain when it has one clear job and predictable inputs.

  • Name the component after the UI role it performs.
  • Avoid mixing data fetching, layout and low-level controls in one component.
  • Pass content through props or children when reuse matters.
Starter codeCopy and adapt this outline for the workflow.
type ReactComponentProps = {
  title: string;
  description: string;
};

export function ReactComponent({
  title,
  description,
}: ReactComponentProps) {
  return (
    <section aria-labelledby="structure-react-component-title">
      <h2 id="structure-react-component-title">{title}</h2>
      <p>{description}</p>
    </section>
  );
}

Work this way

These are the patterns that keep the workflow practical, accessible and easier to maintain.

Name the component after the UI role it performs.
Use clear prop names instead of implementation details.
Keep local UI state inside the component.

Avoid these traps

Putting unrelated layout, data and interaction logic into one component.
Adding too many boolean props instead of composing smaller pieces.
Duplicating derived values in component state.

Step-by-step workflow

Follow the steps in order, then use the resource sections when you need a tool, reference or UI pattern.

1

Define the component responsibility

A component is easier to maintain when it has one clear job and predictable inputs.

  • Name the component after the UI role it performs.
  • Avoid mixing data fetching, layout and low-level controls in one component.
  • Pass content through props or children when reuse matters.
2

Design the props API

Props should make common use cases easy and unusual cases possible without adding noise.

  • Use clear prop names instead of implementation details.
  • Keep boolean props limited and meaningful.
  • Prefer composition when variants become too complex.
3

Handle state deliberately

State should live where it is needed and be lifted only when another component must coordinate it.

  • Keep local UI state inside the component.
  • Lift state when sibling components need the same value.
  • Avoid duplicating derived values in state.

Tools, cheatsheets and components

Use these linked DevKitYard sections when the guide moves from planning to doing.

Prototype React-ready UI in ElementYard

Use ElementYard to explore component layout and visual variants before implementing React boundaries.

Open ElementYard

React component questions

Should every React component be reusable?

No. Page-specific components are fine, but shared components should have clear props, accessible defaults and predictable variants.

When should I split a React component?

Split it when one part has a separate responsibility, is reused elsewhere or makes the parent component hard to scan.