Should the __layout load called earlier than Page load ? #4374
-
|
I want to bring out this point about When you hit While if you think your page as a hierarchy, Page is actually a child of __layout. But the load execution flow is in opposite direction, its the page first & then the layout. This creates issues where you might want to leverage This is probably not a big deal, but having the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
Another interesting approach would be parallel execution. Remix (in the React world) does this for performance reasons in highly nested layout-and-page-structures. But I am not sure if there is any real-world scenario where this is really necessary (and not just fancy). |
Beta Was this translation helpful? Give feedback.
-
|
What makes you say that the <!-- __layout.svelte -->
<script context="module">
export function load() {
console.log('layout load');
return {};
}
</script>
<main>
<slot />
</main>
<!-- index.svelte -->
<script context="module">
export function load() {
console.log('page load');
return {};
}
</script>
<h1>Hello world</h1>... and navigate to So the This matches how the docs talk about
|
Beta Was this translation helpful? Give feedback.
-
Wow, Thanks for pointing it out. My bad, you are right my log is actually inside the |
Beta Was this translation helpful? Give feedback.
What makes you say that the
indexload function is called first? If you have the following...... and navigate to
localhost:3000, the console will log the following:So the
__layoutload function is executed first, then the page. Do you have an example where that isn't happening?This matches how the docs talk about
stuffas being something that's passed from a…