diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index 5e1b5f8128..0b50c5bed1 100755 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -83,7 +83,7 @@ const Breadcrumb: BreadcrumbInterface = ({ }) => { const { getPrefixCls, direction } = React.useContext(ConfigContext); - let crumbs; + let crumbs: React.ReactNode; const prefixCls = getPrefixCls('breadcrumb', customizePrefixCls); if (routes && routes.length > 0) { // generated by route diff --git a/components/breadcrumb/BreadcrumbItem.tsx b/components/breadcrumb/BreadcrumbItem.tsx index 944421581c..12521f738e 100644 --- a/components/breadcrumb/BreadcrumbItem.tsx +++ b/components/breadcrumb/BreadcrumbItem.tsx @@ -43,7 +43,7 @@ const BreadcrumbItem: BreadcrumbItemInterface = ({ return breadcrumbItem; }; - let link; + let link: React.ReactNode; if ('href' in restProps) { link = ( @@ -60,7 +60,7 @@ const BreadcrumbItem: BreadcrumbItemInterface = ({ // wrap to dropDown link = renderBreadcrumbNode(link); - if (children) { + if (children !== undefined && children !== null) { return (
  • {link} diff --git a/components/breadcrumb/__tests__/Breadcrumb.test.tsx b/components/breadcrumb/__tests__/Breadcrumb.test.tsx index 430d25321d..a1855c3cfd 100644 --- a/components/breadcrumb/__tests__/Breadcrumb.test.tsx +++ b/components/breadcrumb/__tests__/Breadcrumb.test.tsx @@ -157,4 +157,15 @@ describe('Breadcrumb', () => { ); expect(asFragment().firstChild).toMatchSnapshot(); }); + it('should support string `0` and number `0`', () => { + const { container } = render( + + {0} + 0 + , + ); + expect(container.querySelectorAll('.ant-breadcrumb-link')[0].textContent).toBe('0'); + expect(container.querySelectorAll('.ant-breadcrumb-link')[1].textContent).toBe('0'); + expect(container.firstChild).toMatchSnapshot(); + }); }); diff --git a/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.tsx.snap b/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.tsx.snap index af7651be21..afe350f4de 100644 --- a/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.tsx.snap +++ b/components/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.tsx.snap @@ -323,3 +323,36 @@ exports[`Breadcrumb should support custom attribute 1`] = ` `; + +exports[`Breadcrumb should support string \`0\` and number \`0\` 1`] = ` + +`;