-
-
Notifications
You must be signed in to change notification settings - Fork 446
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
Persistent Layouts don't render with Inertia/Svelte #898
Comments
The code related to persisted layout should go in Svelte's context module script block, not the main script block. <style>
h1 { font-size: var(--size-12); }
</style>
<h1>{greeting}</h1>
<p>I'm an example home page.</p>
<script context="module">
import DefaultLayout from '@/layouts/default.svelte';
export const layout = DefaultLayout;
</script>
<script>
import { inertia, Link } from '@inertiajs/inertia-svelte';
export let greeting;
</script> |
Hi @pedroborges, thanks for the help, that fixed it. Sorry for what turned out to be a mistake reading the docs. For future reference in case anyone else lands here by googling, setting the default layout in my main function didn't work because I'm bundling with Vite, and thus using |
@burlesona Thank you for this, I try to add async/await and I faced another issue that said |
@burlesona Thanks for this, I seem to be able to get the layout picked up by default using async/await import syntax but my slot is always empty, would you be able to share your entry point by any chance? Thanks! |
Helped a lot by this article https://dev.to/buhrmi/setting-up-a-new-rails-7-app-with-vite-inertia-and-svelte-c9e |
Oh my, reading is hard, even for me. Somehow I completely overlooked that... Thanks for the help! |
Versions:
@inertiajs/inertia
version: 0.10.1@inertiajs/inertia-svelte
version: 0.7.4Describe the problem:
Following the example from the documentation at https://inertiajs.com/pages I set up my Svelte component to use a persistent layout.
The default layout looks like this:
The layout does not render.
However if I change this to a "non-persistent layout" it works exactly as expected.
I'm not getting any errors, but I do see the following warnings in the console:
Specifically the message
<Home> received an unexpected slot "default".
seems related, but note that this warning appears whether with both versions (persistent and non-persistent), and googling it turns up this issue which indicates this may not be a real error.Also since the code works exactly correctly using the "non-persistent" version, I'm inclined to think that something in the inertia plumbing isn't hooked up right.
For reference, I also tried doing this by setting it up as a default layout in the main function:
This had no effect, the result was exactly the same as using
export layout
from the home page component.Steps to reproduce:
Described in detail above.
The text was updated successfully, but these errors were encountered: