I am starting with React and Typescript and my code editor is claiming about my Button component (error bellow), but to eslint
seems to be fine.
import React from 'react'
interface Props {
children: React.ReactChild | React.ReactChildren
}
const Button: React.FunctionComponent = ({ children }: Props) => {
return <button>{children}</button>
}
export default Button
The error:
Type '({ children }: Props) => JSX.Element' is not assignable to type 'FunctionComponent<{}>'.
Types of parameters '__0' and 'props' are incompatible.
Type '{ children?: ReactNode; }' is not assignable to type 'Props'.
Types of property 'children' are incompatible.
Type 'ReactNode' is not assignable to type 'string | number | ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<...>)> | ReactChildren'.
Type 'undefined' is not assignable to type 'string | number | ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) =>
What is wrong on my code?
question from:
https://stackoverflow.com/questions/65870799/jsx-element-is-not-assignable-to-type-functioncomponent 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…