diff --git a/components/page-header/index.tsx b/components/page-header/index.tsx index 0f9efe0f0e..b6d7cc2be6 100644 --- a/components/page-header/index.tsx +++ b/components/page-header/index.tsx @@ -9,6 +9,7 @@ import Breadcrumb, { BreadcrumbProps } from '../breadcrumb'; import Avatar, { AvatarProps } from '../avatar'; import TransButton from '../_util/transButton'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; +import useDestroyed from '../_util/hooks/useDestroyed'; export interface PageHeaderProps { backIcon?: React.ReactNode; @@ -121,8 +122,11 @@ const renderChildren = (prefixCls: string, children: React.ReactNode) => ( const PageHeader: React.FC = props => { const [compact, updateCompact] = React.useState(false); + const isDestroyed = useDestroyed(); const onResize = ({ width }: { width: number }) => { - updateCompact(width < 768); + if (!isDestroyed()) { + updateCompact(width < 768); + } }; return (