Closed DairAidarkhanov closed 4 years ago
I think I know what the problem is: Lazy component does not propagate params through the Route, so the workaround is to introduce a new param inside the <Lazy />
component.
Something like this should work: <Lazy component={...} {params} />
.
Here is the working example that fixes params propagation to lazy component. But this would introduce fiddling around with params leading to unnecessary redundancy.
Now, there is a trade-off: either include standard <Lazy />
component in tinro but increasing the bundle size or have another design considerations to lazy loading.
Thanks, good catch. But I just forgot to edit Readme when update tinro's API some time ago. Use router.params()
instead router.getParams()
=)
What?! Yeah, that was unexpected. Thanks!
For anyone looking for the proper example: https://svelte.dev/repl/311a206abbf94113be46787256e74e24?version=3.22.3
Hello, thank you once again for this library!
I have a weird problem with getting url params inside lazy loaded components.
Let's imagine we have a lazy component inside a route
<Route path="/:name"><Lazy component={...}></Route>
.When I call
router.getParams()
method inside the component, I get an error:TypeError: (intermediate value).getParams is not a function
Here is the example I put up in REPL (for code overview) and a ready environment with the example: svelte-app.zip