How to bind the data to slot #13109
Answered
by
brunnerh
karchung0930
asked this question in
Q&A
-
I have the below on
I want to make the |
Beta Was this translation helpful? Give feedback.
Answered by
brunnerh
Sep 3, 2024
Replies: 1 comment
-
You cannot pass data to slots in SvelteKit since the code that uses the components is autogenerated. Your options are either:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
karchung0930
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You cannot pass data to slots in SvelteKit since the code that uses the components is autogenerated.
Slot properties also cannot be bound, they are one-way.
Your options are either:
load
function - any data returned from there will be available in thedata
property of the layout and any child layouts/pages.The data cannot be changed in a child to update the parent.
If the data should be reactive from child to parents (e.g. the page changes the value and the layout updates), you need to use a writable store (or in Svelte 5 a
$state
object whose properties can be changed).