Skip to content

Components

Learn how to build reusable components in aincraft.

Components are the building blocks of your application.

Create a new component:

export default function MyComponent() {
return <div>Hello World</div>;
}

Pass data to components using props:

function Greeting({ name }) {
return <h1>Hello, {name}!</h1>;
}

Compose smaller components into larger ones.

Manage component lifecycle with hooks:

  • onMount - When component is mounted
  • onUnmount - When component is unmounted
  • onChange - When component state changes
  • Keep components small and focused
  • Use descriptive names
  • Document component props