Skip to content

Commit

Permalink
fix: temp fix for MemoryRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Sep 22, 2022
1 parent 41cd261 commit 555a7d2
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/widget/src/hooks/useNavigateBack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit 555a7d2

Please sign in to comment.