svelte-navigator
svelte-navigator copied to clipboard
two updates from useLocation() on page reload
I have the following app:
//App.svelte
<script>
import { Route, Router } from 'svelte-navigator'
import Temp from './Temp.svelte'
</script>
<Router>
<Route path="/temp" component={Temp} />
</Router>
//Temp.svelte
<script>
import { useLocation } from 'svelte-navigator'
const location$ = useLocation()
$: console.log(JSON.stringify($location$))
</script>
After going to /temp path (or refreshing) there are two identical messages in console:
{"pathname":"/temp","hash":"","search":"","state":null}
{"pathname":"/temp","hash":"","search":"","state":null}
Why is the reactive statement called twice if the location didn't change?