The question is very similar to this, but mine is focused on the default function. (I'm new to front-end, please let me know if there's a more official name for it)
This is the code (I'm using TypeScript 2.5):
export const TestProps = {
Hello: (name: string) => {
console.log(name);
}
}
type TestPropsType = typeof TestProps;
export class TestComp extends React.Component<TestPropsType, {}>{
public render() {
this.props.Hello("world");
return <div>test</div>;
}
}
Then, when I try to render this component:
ReactDOM.render(<TestComp />, document.getElementById("page"));
I got this error;
TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }> & ...'. Type '{}' is not assignable to type 'Readonly<{ Hello: (name: string) => void; }>'.
Property 'Hello' is missing in type '{}'.
How can I fix this problem?