From 3713083a9420b0cbc1f2ee042d1e2b30c8ac1169 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Wed, 31 May 2023 01:39:51 +0000 Subject: [PATCH] set location to `/` if cannot back --- packages/app/src/router.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/app/src/router.jsx b/packages/app/src/router.jsx index 31b3df25..f09ce3f8 100755 --- a/packages/app/src/router.jsx +++ b/packages/app/src/router.jsx @@ -176,7 +176,14 @@ export const PageRender = React.memo((props) => { } app.backLocation = (state = {}) => { - return navigate(app.location.lastPathname, { + let to = app.location.lastPathname + + if (!to || to === app.location.pathname) { + console.warn("No last location found, redirecting to /") + to = "/" + } + + return navigate(to, { state }) }