diff --git a/components/page-header/__tests__/index.test.js b/components/page-header/__tests__/index.test.js
index d7b74564f2..c54ea09c8d 100644
--- a/components/page-header/__tests__/index.test.js
+++ b/components/page-header/__tests__/index.test.js
@@ -1,6 +1,7 @@
import React from 'react';
import { mount, render } from 'enzyme';
import PageHeader from '..';
+import Breadcrumb from '../../breadcrumb';
import ConfigProvider from '../../config-provider';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
@@ -50,6 +51,20 @@ describe('PageHeader', () => {
expect(wrapper.find('.ant-page-header-back')).toHaveLength(0);
});
+ it('pageHeader should have breadcrumb (component)', () => {
+ const routes = [
+ {
+ path: 'index',
+ breadcrumbName: 'First-level Menu',
+ },
+ ];
+ const wrapper = mount(
+ } />,
+ );
+ expect(wrapper.find('.ant-breadcrumb')).toHaveLength(1);
+ expect(wrapper.find('.ant-page-header-back')).toHaveLength(0);
+ });
+
it('pageHeader support breadcrumbRender', () => {
const wrapper = mount(
test
} />,
diff --git a/components/page-header/index.tsx b/components/page-header/index.tsx
index 9061e758d2..5a3ef44cd8 100644
--- a/components/page-header/index.tsx
+++ b/components/page-header/index.tsx
@@ -16,7 +16,7 @@ export interface PageHeaderProps {
title?: React.ReactNode;
subTitle?: React.ReactNode;
style?: React.CSSProperties;
- breadcrumb?: BreadcrumbProps;
+ breadcrumb?: BreadcrumbProps | React.ReactElement;
breadcrumbRender?: (props: PageHeaderProps, defaultDom: React.ReactNode) => React.ReactNode;
tags?: React.ReactElement | React.ReactElement[];
footer?: React.ReactNode;
@@ -156,10 +156,13 @@ const PageHeader: React.FC = props => {
const defaultBreadcrumbDom = getDefaultBreadcrumbDom();
+ const isBreadcrumbComponent = breadcrumb && 'props' in breadcrumb;
// support breadcrumbRender function
- const breadcrumbDom =
+ const breadcrumbRenderDomFromProps =
breadcrumbRender?.(props, defaultBreadcrumbDom) || defaultBreadcrumbDom;
+ const breadcrumbDom = isBreadcrumbComponent ? breadcrumb : breadcrumbRenderDomFromProps;
+
const className = classNames(prefixCls, customizeClassName, {
'has-breadcrumb': !!breadcrumbDom,
'has-footer': !!footer,