我遇到了以下错误:
Type '(props: PropsWithChildren<{ amount: number; }>) => string' is not assignable to type 'FC<{ amount: number; }>'.
Type 'string' is not assignable to type 'ReactElement<any, any> | null'.ts(2322)
当使用以下 TypeScript 函数时,不理解问题所在,希望得到任何帮助,谢谢!
代码如下:
const MoneyAmount: React.FC<{amount : number}> = (props) => {
return (
new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD",
maximumFractionDigits: 4
}).format(props.amount))
}
export default MoneyAmount ;