Closed iShawnWang closed 2 years ago
这次提交会引发这个警告。
[0] components/toast/index.tsx(59,5): error TS2322: Type '{ content: React.ReactNode; duration: number | undefined; onClose: (() => void) | undefined; mask: boolean | undefined; stackable?: boolean | undefined; type: string; }' is not assignable to type '{ content: string; type: string; duration: number | undefined; onClose: (() => void) | undefined; mask: boolean | undefined; stackable?: boolean | undefined; }'.
[0] Types of property 'content' are incompatible.
[0] Type 'ReactNode' is not assignable to type 'string'.
[0] Type 'undefined' is not assignable to type 'string'.
问题
根据 ant design rn 的文档 : https://rn.mobile.ant.design/components/toast-cn/ Toast 的 content 类型是 :
React.Element | String
实际现在的代码不能支持 content 是自定义 view, 会报Nesting View components inside Text components not working correctly
错误解决方案
如 PR 代码... 判断 typeof content === 'string'