mefechoel / svelte-navigator

Simple, accessible routing for Svelte

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

two updates from useLocation() on page reload

betfix opened this issue · comments

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?