This works fine:
import React, { FunctionComponent } from "react";
const Counter: FunctionComponent = () => <div>hello from Counter</div>;
export default Counter;
This has compile error:
import React, { FunctionComponent } from "react";
function Counter1(): FunctionComponent {
return <div>hello from Counter1</div>;
}
export default Counter1;
The error says:
Type 'Element' is not assignable to type 'FunctionComponent<{}>'.
Type 'Element' provides no match for the signature '(props: { children?: ReactNode; }, context?: any): ReactElement ReactElement Component)>) | (new (props: any) => Component)>'.ts(2322)
How to write functional component with FunctionComponent type using "function" syntax?