| name | react-component |
| description | Creates React components following arolariu.ro patterns: Server Components by default, Island pattern for interactivity, strict TypeScript, Readonly props, accessibility-first, with Vitest tests achieving 90%+ coverage. |
| lastReviewed | 2026-05-08T00:00:00.000Z |
React Component Scaffolding
Generates React components following the arolariu.ro frontend patterns.
When to Use
- Creating a new page with the Island pattern
- Adding a reusable component to the shared library
- Creating a new Client Component with state management
- Building a form with validation
Component Types
Server Component (Default)
Use for pages that fetch data and render static content.
import type {Metadata} from "next";
import {createMetadata} from "@/metadata";
import {getTranslations} from "next-intl/server";
import RenderScreen from "./island";
export async function generateMetadata(): Promise<Metadata> {
const t = await getTranslations("Namespace.__metadata__");
return createMetadata({title: t("title"), description: t("description")});
}
export default async function PageName(): Promise<React.JSX.Element> {
const data = await fetchServerData();
return <RenderScreen initialData={data} />;
}
Client Component (Island)
Use for interactive content that needs browser APIs, event handlers, or React hooks.
"use client";
import {useState} from "react";
import {useTranslations} from "next-intl";
interface Props {
readonly initialData: DataType[];
}
export default function RenderScreen({
initialData,
}: Readonly<Props>): React.JSX.Element {
const t = useTranslations("Namespace");
const [items, setItems] = useState(initialData);
return (
<main className="container mx-auto px-4 py-8">
<h1 className="text-3xl font-bold">{t("title")}</h1>
{/* Interactive content */}
</main>
);
}
Custom Hook
Use for reusable stateful logic.
import {useState, useEffect} from "react";
interface UseEntityOptions {
readonly entityId: string;
}
interface UseEntityResult {
readonly entity: EntityType | null;
readonly isLoading: boolean;
readonly error: Error | null;
}
export function useEntity({entityId}: UseEntityOptions): UseEntityResult {
const [entity, setEntity] = useState<EntityType | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
( {
isMounted = ;
fetchData = (): <> => {
{
data = (entityId);
(isMounted) (data);
} (err) {
(isMounted) (err ? err : ());
} {
(isMounted) ();
}
};
();
{ isMounted = ; };
}, [entityId]);
{entity, isLoading, error};
}
Shared UI Component
For @arolariu/components library.
import * as React from "react";
import {cn} from "@/lib/utils";
interface ComponentNameProps extends React.HTMLAttributes<HTMLDivElement> {
variant?: "default" | "outline";
}
const ComponentName = React.forwardRef<HTMLDivElement, ComponentNameProps>(
({className, variant = "default", ...props}, ref) => {
return (
<div
ref={ref}
className={cn("base-styles", className)}
{...props}
/>
);
},
);
ComponentName.displayName = "ComponentName";
export {ComponentName};
export type {ComponentNameProps};
Test Template
import {describe, expect, it, vi} from "vitest";
import {render, screen, waitFor} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
describe("ComponentName", () => {
it("should render without crashing", () => {
render(<ComponentName />);
expect(screen.getByRole("main")).toBeInTheDocument();
});
it("should display initial data", () => {
render(<ComponentName initialData={mockData} />);
expect(screen.getByText("Expected Text")).toBeInTheDocument();
});
it("should handle user interaction", async () => {
const user = userEvent.setup();
render(<ComponentName />);
await user.click(screen.getByRole("button", {name: /submit/i}));
( {
(screen.()).();
});
});
});
Checklist
RFC Grounding Checklist (Mandatory)
Before final output or code changes:
- Map task scope to relevant RFC IDs using
.github/agent-governance/rfc-grounding-protocol.md.
- Read the referenced source files and verify RFC guidance is still current.
- If RFC and source conflict, follow source-of-truth code and record RFC drift for remediation.
- Include concrete evidence in outputs (file paths, command results, and validation notes).
Execution Contract
Prerequisites
- Confirm feature scope and expected behavior before creating or modifying files.
- Identify whether this task changes architecture-sensitive behavior and trigger RFC grounding.
Required Context Reads
.github/instructions/frontend.instructions.md
.github/instructions/react.instructions.md
.github/instructions/typescript.instructions.md
docs/rfc/1002-comprehensive-jsdoc-documentation-standard.md
docs/rfc/1007-advanced-frontend-patterns.md
File Mutation Boundaries
- Allowed:
sites/arolariu.ro/src/** and packages/components/** only when requested.
- Disallowed: workflow/infra/backend edits unless explicitly requested.
Validation Commands
npm run test:website
npm run lint
Success Output Contract
- Return created/updated file paths.
- Summarize validation commands and outcomes.
- Report assumptions made during generation.
Failure Output Contract
- Report failing step and exact error output.
- Provide impacted files and rollback-safe next steps.
- Request user confirmation when risk or ambiguity blocks safe continuation.
Self-Audit and Uncertainty Protocol (Mandatory)
For non-trivial tasks, complete this checklist before final output:
- Assumptions: list non-obvious assumptions that influenced decisions.
- Risk Flags: identify security, behavior, deployment, or data risks.
- Confidence: report
high, medium, or low with brief justification.
- Evidence: cite changed files, executed commands, and validation outcomes.
Escalate to the user before continuing when security/auth/infra/destructive or major behavior-changing decisions are involved.