-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Bug with slot props variables #2586
Comments
I might be wrong here, but I believe this is intentional to maintain a one-way data flow and the slot is only able to expose data that was passed down as props from the parent. Similar to the concept of scoped slots in Vue or render props in React. |
I was playing around with this again today and see what you mean. I am not sure the reason why you can't create a variable and define it's value in a one-liner. Perhaps it has something to do with the reactivity, but your guess is as good as mine. Hopefully someone will chime in soon and shed some light. |
Well that's weird. I'm not sure why it breaks in that example but not in https://svelte.dev/examples#slot-props |
The difference seems to be that scalar values don't work, but object (and maybe array, can't remember exactly) do. |
It's True, objects and arrays work |
* Fixed bug with slot props variables * dont add hoisted items to context * alternative fix for #2586 * update slots more conservatively
Fixed at last in 3.6.2, thank you! https://svelte.dev/repl/0597c56d480e14ebe6b5aa7017dd7051?version=3.6.2 |
Repl
https://svelte.dev/repl?version=3.1.0&gist=0597c56d480e14ebe6b5aa7017dd7051
Problem
I try to expose value from
<slot>
, but getundefined
Solving methods
export
Why I can't declare variable like usually?
The text was updated successfully, but these errors were encountered: