React TypeScript Component Stub Builder

Generate a typed React component with props interface and basic structure

Create a React functional component stub in TypeScript — a typed props interface, optional useState hooks, the function declaration with destructured props, basic JSX, and a default or named export following modern React conventions.

Why not use React.FC?

React.FC was once standard but it implicitly types children and complicates generics, so the React team and most style guides now recommend typing props directly on the function parameter. This stub follows that convention.

A typed React component, scaffolded correctly

Every React component in a TypeScript codebase starts the same way: a props interface, a function that destructures those props, some JSX, and an export. Getting the typing right — optional props, no implicit any, the right export style — is easy to fumble. This builder emits a clean, modern stub from a name and a prop list.

How it works

The tool parses your prop lines (name: type, with a trailing ? on the name marking it optional) into a TypeScript interface ComponentNameProps. It then writes function ComponentName({ ...destructured }: ComponentNameProps) { ... }, typing props directly on the parameter rather than using React.FC. If you enable state it imports useState and adds one const [value, setValue] = useState(...) hook. The body returns a minimal JSX wrapper that renders the props so the file compiles and renders immediately. Finally it appends either export default ComponentName or a named export.

Tips and example

  • Type props on the parameter, not via React.FC, to avoid implicit children and generic friction.
  • Mark genuinely optional props with ?; required props should stay required to catch missing data early.
  • Keep the stub presentational; lift data fetching into a parent or a hook for testability.
interface GreetingProps {
  name: string;
  excited?: boolean;
}

export default function Greeting({ name, excited }: GreetingProps) {
  return <p>Hello, {name}{excited ? "!" : "."}</p>;
}