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);

© 2021-2023 Million Software, Inc.