-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] Prevent needless prop updates causing rerenders
Fixes #5247 by not adding unchanged layout or page props to the root props
- Loading branch information
1 parent
3a0c210
commit 0dc0dd2
Showing
6 changed files
with
43 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Prevent needless prop updates causing rerenders |
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
22 changes: 22 additions & 0 deletions
22
packages/kit/test/apps/basics/src/routes/load/layout-props/__layout.svelte
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,22 @@ | ||
<script context="module"> | ||
/** @type {import('@sveltejs/kit').Load} */ | ||
export async function load() { | ||
return { | ||
props: { | ||
// Needs to be an object, else Svelte will do by-value-comparison and skip rerender | ||
obj: {} | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
<script> | ||
/** @type {any} */ | ||
export let obj; | ||
let count = 0; | ||
$: obj && count++; | ||
</script> | ||
|
||
<h1>{count}</h1> | ||
<slot /> |
2 changes: 2 additions & 0 deletions
2
packages/kit/test/apps/basics/src/routes/load/layout-props/a.svelte
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,2 @@ | ||
<h2>On a</h2> | ||
<a href="/load/layout-props/b">to b</a> |
2 changes: 2 additions & 0 deletions
2
packages/kit/test/apps/basics/src/routes/load/layout-props/b.svelte
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,2 @@ | ||
<h2>On b</h2> | ||
<a href="/load/layout-props/a">to a</a> |
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