ant-design / ant-design-mobile-rn

Ant Design for React Native
https://rn.mobile.ant.design/
MIT License
3.04k stars 612 forks source link

feat: 支持自定义 Toast content #1160

Closed iShawnWang closed 2 years ago

iShawnWang commented 3 years ago

问题

根据 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'

erichua23 commented 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'.