From 555a7d24fd4e8345dc091ea631a0f8461f37f393 Mon Sep 17 00:00:00 2001 From: Eugene Chybisov Date: Thu, 22 Sep 2022 16:11:20 +0100 Subject: [PATCH] fix: temp fix for MemoryRouter --- packages/widget/src/hooks/useNavigateBack.ts | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/widget/src/hooks/useNavigateBack.ts b/packages/widget/src/hooks/useNavigateBack.ts index 0a8e30782..5321c7e53 100644 --- a/packages/widget/src/hooks/useNavigateBack.ts +++ b/packages/widget/src/hooks/useNavigateBack.ts @@ -5,17 +5,19 @@ export const useNavigateBack = () => { const navigate = useNavigate(); const navigateBack = useCallback(() => { - if (window.history.state && window.history.state.idx > 0) { - navigate(-1); - } else { - navigate( - window.location.pathname.substring( - 0, - window.location.pathname.lastIndexOf('/'), - ) || '/', - { replace: true }, - ); - } + // https://github.com/remix-run/react-router/pull/9112 + // + // if (window.history.length > 2) { + navigate(-1); + // } else { + // navigate( + // window.location.pathname.substring( + // 0, + // window.location.pathname.lastIndexOf('/'), + // ) || '/', + // { replace: true }, + // ); + // } }, [navigate]); return { navigateBack, navigate };