Generate a React 19 component from a props list, in TypeScript or JavaScript, using current APIs rather than the patterns React 19 removed.
Turned into PascalCase, which React requires: a lower-case tag is read as an HTML element.
One per line: name, name: type, name?: type, name: type = default. Supported types: string, number, boolean, string[], ReactNode, () => void, object.
A named export survives a rename and autocompletes. A default export is what a Next.js page or a lazy import needs.
A named function carries its name into a stack trace and into React DevTools directly; an arrow gets there by inference.
user-card.tsxtype UserCardProps = {
name: string;
role?: string;
onSelect: () => void;
};
export function UserCard({
name,
role = "member",
onSelect,
}: UserCardProps) {
return (
<div className="user-card">
<span>{name}</span>
<span>{role}</span>
<button type="button" onClick={onSelect}>
Select
</button>
</div>
);
}
Written against React 19. Nothing here is compiled, type-checked or run: the output is assembled from templates, and the only machine check it gets is that every variant of it is put through the real TypeScript parser in this site’s test suite.
React Component Generator runs entirely on your device — the component is assembled in your browser from templates built into the page, and neither the name nor the props you type is sent anywhere.
You’re on the Free plan. Compare plans
Write the props, get the component. One tool with switches rather than a page per variation, because TypeScript or JavaScript, named or default export, function or arrow, memoised or not are all the same generator with a different setting.
The reason it exists is the version. React 19 removed things that every older example still uses, and output built from those examples is wrong the day you paste it. `forwardRef` is unnecessary — `ref` is an ordinary prop on a function component, so wrapping anything in `forwardRef` adds a layer for nothing. `defaultProps` no longer works on a function component, so defaults go in the parameter list. `propTypes` is gone. These are not style preferences; they are the difference between code that works and code that does not.
The props syntax takes a type and a default on the same line, including types that contain an equals sign — `onSelect: () => void = () => {}` parses correctly, which is less obvious than it sounds and is where naive generators produce output that will not even parse. An unrecognised type is reported rather than passed through into the output, so you find out here instead of in your editor.
Each prop is rendered in a way that suits it: an array maps with a key, a boolean renders conditionally, a callback becomes a button handler. The result is a component you edit rather than one you rewrite.
Every option combination is put through the real TypeScript parser in this site's test suite. Nothing is compiled, type-checked or run here, and the page says so — but the templates themselves are known to parse.
Because React 19 passes ref straight through to a function component as a prop. forwardRef still works, but it wraps the component for no benefit. This is the single most common thing generated React code gets wrong, because forwardRef was required for about ten years.
Removed for function components in React 19. A default goes in the destructured parameter list, which is also where it is visible next to the prop it belongs to.
Because an undefined reaching JSX or arithmetic is where the bugs are. An optional string defaults to an empty string, an array to an empty array. Delete it if you want undefined.
Only after measuring. memo adds a shallow prop comparison on every render in exchange for skipping some renders, which is a trade rather than an improvement. The generated export keeps the component's own name either way, so turning it off later is not a change at every call site.
No. It is assembled from templates in your browser, with no compiler involved. Every variant of it is parsed by the real TypeScript parser in this site's test suite, which guarantees the syntax and nothing beyond that.
If a tool here saved you some time, you can put something towards the hosting.Buy me a coffee, on Ko-fi, opens in a new tab