Open billy-onggo opened 12 months ago
I encountered inconsistency on useLocation hook when programmatically navigating routes via navigate(-1) compared to history.back(-1) or hitting the browser's back button.
useLocation
navigate(-1)
history.back(-1)
Is this intented? Given the current documentation states:
navigate(-1) is equivalent to hitting the back button in your browser https://github.com/mefechoel/svelte-navigator/tree/main#parameters-1
Steps to reproduce:
Expected Behaviour The navigate(-1) method should trigger the location change only once
Note:
Sample Code
<script lang="ts"> import { Route, useNavigate, useLocation } from "svelte-navigator"; const navigate = useNavigate() const location = useLocation(); location.subscribe((l) => console.log(l)) </script> <div> <h2>My Nested Route, using navigate</h2> <div> <button on:click={()=> navigate('one')}>one</button> <button on:click={()=> navigate('two')}>two</button> <button on:click={()=> navigate(-1)}>BACK</button> <button on:click={()=> navigate(1)}>FORWARD</button> </div> <div> <Route path="/one" primary={false}>Page One</Route> <Route path="/two" primary={false}>Page Two</Route> </div> </div>
Screenshots
Desktop
I encountered inconsistency on
useLocation
hook when programmatically navigating routes vianavigate(-1)
compared tohistory.back(-1)
or hitting the browser's back button.Is this intented? Given the current documentation states:
Steps to reproduce:
useLocation
. Subscribe to the instance.navigate(-1)
Expected Behaviour The
navigate(-1)
method should trigger the location change only onceNote:
Sample Code
Screenshots
Desktop