diff --git a/components/page-header/__tests__/__snapshots__/index.test.js.snap b/components/page-header/__tests__/__snapshots__/index.test.js.snap index 0e827b03c1..e0345f586a 100644 --- a/components/page-header/__tests__/__snapshots__/index.test.js.snap +++ b/components/page-header/__tests__/__snapshots__/index.test.js.snap @@ -1,5 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`PageHeader pageHeader should not render blank dom 1`] = ` +
+`; + exports[`PageHeader pageHeader should support className 1`] = `
{ ); expect(wrapper).toMatchSnapshot(); }); + + it('pageHeader should not render blank dom', () => { + const wrapper = render(); + expect(wrapper).toMatchSnapshot(); + }); }); diff --git a/components/page-header/index.tsx b/components/page-header/index.tsx index 4c59b7a5a2..f79d526c6b 100644 --- a/components/page-header/index.tsx +++ b/components/page-header/index.tsx @@ -68,14 +68,17 @@ const renderHeader = (prefixCls: string, props: PageHeaderProps) => { const renderTitle = (prefixCls: string, props: PageHeaderProps) => { const { title, subTitle, tags, extra } = props; const titlePrefixCls = `${prefixCls}-title-view`; - return ( -
- {title} - {subTitle && {subTitle}} - {tags && {tags}} - {extra && {extra}} -
- ); + if (title || subTitle || tags || extra) { + return ( +
+ {title && {title}} + {subTitle && {subTitle}} + {tags && {tags}} + {extra && {extra}} +
+ ); + } + return null; }; const renderFooter = (prefixCls: string, footer: React.ReactNode) => {