question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

again: <component> was created with unknown prop 'params'

See original GitHub issue

It seems that this bug is not fully fixed: https://github.com/ItalyPaleAle/svelte-spa-router/issues/83

404-Components still have this issue for me

import NotFound from '../views/404.svelte'
const routes = {
	...
	'*': NotFound, //<<<<<<<
}
...

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
ItalyPaleAlecommented, Apr 2, 2020

This is a good point but it’s not something I can fix.

First, please note that it’s just a warning that Svelte (not the router) emits, so: it won’t break your app, and it’s not something we can disable.

The fix for #83 consisted in passing the params prop only if there’s a match in the path. That is, if your path is a fixed one (such as /hello/world) then there’s nothing matched, so the router doesn’t pass anything to the route. If there’s anything that would create a match, then it’s passed.

In the case of the * route, the router does create a params.wild prop, which matches the page that wasn’t found. And that’s passed to the component.

There’s not much we can do there. It’s not possible for a Svelte component to inspect another Svelte component and check if it exposes any prop (that is only possible if Svelte components are compiled as “custom elements” per https://svelte.dev/docs#Custom_element_API ).

You can only adopt a workaround, which can be one of:

  1. Ignore the warning, given that it’s just a warning anyways. It’s annoying, but it won’t break your app
  2. In your NotFound component, expose the params prop: export let params = {}. You don’t need to use that prop at all, but it being there will disable the warning.

I understand this is not ideal, but sadly this is not something we can change as it’s how Svelte works.

1reaction
frederikhorscommented, Apr 8, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing props down in Svelte - Stack Overflow
With svelte-routing, you don't pass props from the <Link> component, you pass them from the <Route> component implicitly.
Read more >
Useful Patterns by Use Case - React TypeScript Cheatsheets
Usecase: you want to make a <Button> that takes all the normal props of ... then you can use ComponentPropsWithRef to grab props...
Read more >
History - React Router: Declarative Routing for React.js
Therefore it is recommended to access the location from the render props of <Route> , not from history.location . This ensures your assumptions...
Read more >
Troubleshooting | React Navigation
Here, every time the component re-renders, a new function will be created and passed to the component prop. React will see a new...
Read more >
How to Use React Router in Typescript | Pluralsight
We'll start by creating an empty application using Create React App ... parameter, so in order to use it, we spread the component...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found