Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

two updates from useLocation() on page reload #41

Open
betfix opened this issue Jul 7, 2021 · 0 comments
Open

two updates from useLocation() on page reload #41

betfix opened this issue Jul 7, 2021 · 0 comments

Comments

@betfix
Copy link

betfix commented Jul 7, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant