-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When changing page, but in the same component, the page was not refreshed. There was these two issues: * No transition * Some part of the page is not updated The reason was because Svelte reused the exact same component (so no mount / destroy and no animation on component creation / destruction). To correctly update the page, we change the `Page` component by adding a keyed-each block (see sveltejs/svelte#1469). There was some issue with this solution because each time we update the component, the render is updated so the Page and create an infinite loop. To avoid this problem, we remove the call to `Page` component from concrete pages and include it directly with the Router. To do so, we create the PageRoute component behaving as expected.
- Loading branch information
Gaëtan Rizio
committed
May 17, 2020
1 parent
6490449
commit 07525df
Showing
8 changed files
with
178 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script> | ||
import { Router, Route, links } from "svelte-routing" | ||
import Page from "./Page.svelte" | ||
/** @type {string} */ | ||
export let path | ||
/** @type {any} */ | ||
export let component | ||
</script> | ||
|
||
<Route path={path} let:location={location} let:params={routeParams}> | ||
{#each [`${Date.now()}-${Math.random()}`] as x(x)} | ||
<Page> | ||
<svelte:component this={component} location={location} {...routeParams} /> | ||
</Page> | ||
{/each} | ||
</Route> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.