fix: 修复当 toast 内容是个对象时不显示问题 (#4528)

Co-authored-by: liaoxuezhi <2betop.cn@gmail.com>
This commit is contained in:
吴多益 2022-06-06 15:27:25 +08:00 committed by GitHub
parent 6df8179193
commit a35ca4e477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -12,7 +12,8 @@
"stop": "fis3 server stop",
"dev": "fis3 release -cwd ./public",
"deploy-gh-page": "sh ./deploy-gh-pages.sh",
"test": "jest",
"test": "npm test --workspaces",
"prepare": "husky install"
"coverage": "jest --coverage",
"release": "lerna publish",
"release:beta": "lerna publish --canary --pre-dist-tag=beta --preid beta --yes"
@ -33,6 +34,7 @@
"fis3-prepackager-stand-alone-pack": "^1.0.0",
"fis3-preprocessor-js-require-css": "^0.1.3",
"fis3-preprocessor-js-require-file": "^0.1.3",
"husky": "^8.0.0"
"jest": "^28.1.0",
"jest-environment-jsdom": "^28.1.0",
"lerna": "^5.0.0",

View File

@ -388,14 +388,18 @@ export class ToastMessage extends React.Component<
})
) : null}
{typeof body === 'string' ? (
<div className={cx('Toast-body')}>
{allowHtml ? <Html html={body} /> : body}
</div>
) : React.isValidElement(body) ? (
{React.isValidElement(body) ? (
React.cloneElement(body, {
className: cx(`Toast-body`, body?.props?.className ?? '')
})
) : typeof body === 'string' || typeof body === 'object' ? (
<div className={cx('Toast-body')}>
{allowHtml ? (
<Html html={body?.toString()} />
) : (
body?.toString()
)}
</div>
) : null}
</div>