svelte-routing: was created with unknown prop 'location'

If use: <Route exact path="about"><About /></Route> All good. If use: <Route exact path="about" component={About} /> About.svelte:14 <About> was created with unknown prop ‘location’ About.svelte:14 <About> was created with unknown prop ‘exact’

Any ideal?

“svelte”: “^3.20.1” “svelte-routing”: “^1.4.2”

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 12
  • Comments: 15 (1 by maintainers)

Commits related to this issue

Most upvoted comments

hey, @EmilTholin this package becoming popular. you should fix all of the bugs. I saw that the latest version is a year ago. please fix the bug

I get this warning if I do: <Route path="post" component="{Post}" /> but not when I do <Route path="post"><Post /></Route>

In the About component add: export let location;

I’m having the same exact issue.

PS use URLSearchParams instead of query-string

@EmilTholin I obviously have the same issue but was thinking that since the location prop is not always used by components would it not make sense to rather expose make it available via context/store (IIRC there is getContext(LOCATION) or some store).

I’m not super familiar with svelte-routing internals but something like:

<!-- Blog.svelte -->
<script>
  import { location } from 'svelte-routing';
  import queryString from "query-string";

  let queryParams;
  $: queryParams = queryString.parse($location.search);
</script>

<h1>Blog</h1>
<p>{queryParams.foo}</p>

EDIT: Interestingly I’ve just seen that svelte-spa-router does as I’m suggesting for both $location and $querystring.