From 1d4952cf60b30c44fcaf4e30df5ec152a6e961e6 Mon Sep 17 00:00:00 2001 From: zhangjingwei Date: Thu, 15 Jul 2021 09:07:16 +0800 Subject: [PATCH] fix: Fix display currectly after jumping from the error page Fix display currectly after jumping from the error page Change-Id: I3ec80b38d7b4f330c7e65d4e54d6b70668bc6e0d --- src/layouts/Base/Right.jsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/layouts/Base/Right.jsx b/src/layouts/Base/Right.jsx index 1f505e4b..9575c3ee 100644 --- a/src/layouts/Base/Right.jsx +++ b/src/layouts/Base/Right.jsx @@ -35,10 +35,22 @@ class Right extends Component { }; } + componentDidUpdate(prevProps) { + const { location: { pathname: oldPath } = {} } = prevProps; + const { location: { pathname: newPath } = {} } = this.props; + if (oldPath !== newPath) { + this.updateErrorState(false); + } + } + static getDerivedStateFromError() { return { hasError: true }; } + componentDidCatch(error, errorInfo) { + console.log(error, errorInfo); + } + get isAdminPage() { return this.props.isAdminPage || false; } @@ -56,6 +68,12 @@ class Right extends Component { return hasTab || false; }; + updateErrorState(flag) { + this.setState({ + hasError: flag, + }); + } + renderBreadcrumb = (currentRoutes = []) => { if (!currentRoutes || currentRoutes.length === 0) { return null;