Docs
Usage with TypeScript

Usage with Typescript

If your project uses TypeScript, you may want to make your components type-safe.

⚠️

You must make your Props use type instead of interface, as this is the officially recognized behavior (opens in a new tab) by the Typescript team. Alternatively, if you want to use interfaces you can add [key: string]: any as per this Stack Overflow comment (opens in a new tab).

type Props = {
  name: string,
};
 
const MyComponent: React.FC<Props> = ({ name }) => {
  return <div>Hello {name}</div>;
};
const MyBlock = block(MyComponent);