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

Add the way to get routing params to via props #12

Merged
merged 1 commit into from
May 23, 2024
Merged

Add the way to get routing params to via props #12

merged 1 commit into from
May 23, 2024

Conversation

ykrods
Copy link
Owner

@ykrods ykrods commented May 22, 2024

In svelte5, the error like <MyComponent> was created with unknown prop 'xxx' when passing a dynamic property with <svelte:component> will be resolved. In addition, store is deprecated from svelte 5 .
Therefore, we are considering changing to assign route params to a component property called params instead of using store, and changing routeParams store to deprecated.

example

<!-- App.svelte -->
<script lang="ts">
  import Router from "svelte-spa-history-router";

  const routes = [
    { path: "/item/(?<id>.+)", component: MyComponent }
  ];
</script>
<Route {routes}/>


<!-- MyComponent.svelte -->
<script lang="ts">
  import type { RouteParams } from "svelte-spa-history-router";

  let { params }: { params: RouteParams } = $props();
</script>
<div>{ params.id }</div>

svelte 5 is still in the rc stage, so we'll wait and see how it goes to merge to main.

@ykrods ykrods changed the base branch from main to next May 23, 2024 04:01
@ykrods ykrods merged commit cb4cc5c into next May 23, 2024
@ykrods ykrods deleted the params-prop branch May 23, 2024 04:01
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

Successfully merging this pull request may close these issues.

1 participant