Slot renders 'undefined' when passed an undefined variable
See original GitHub issueDescribe the bug
Passing an undefined variable to a component that uses <slot/>
renders undefined
To Reproduce https://svelte.dev/repl/d2fd61d90bca4e6f870950f9eb29b76b?version=3.14.0
Expected behavior
Nothing is render in the slot. This matches the behaviour of passing nothing like <Component></Component>
Severity Not critical but it forces you user of the component to ensure the property passed is initialised rather than the component internally controlling this.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Undefined Slot variable in Laravel
I am getting an error which is "Undefined variable: nav". In my home.blade.php,I have this code @extends('master') @section('content') ...
Read more >Blade Slot - Undefined variable $slot
Blade Slot - Undefined variable $slot ... public function render() { return view('master'); } } ... <x-master-layout> Helo from slot </x-master-layout>.
Read more >Blade Templates - Laravel - The PHP Framework For Web ...
You are not limited to displaying the contents of the variables passed to the ... This value will be rendered if the section...
Read more >cannot read properties of undefined (reading 'component')
The problem is that as an Input variable, the reminders object is initially undefined until angular has finished initializing the component.
Read more >Google Publisher Console messages
Many Google Publisher Console messages use variables to provide ... Div ID passed to googletag.display() does not match any defined slots: ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@nitro52,
I do this in the component to avoid having checks all over the place:
Adding this functionality to the core would only muddy the waters since there’s situations where you actually want a canary “undefined” to show up so that you know right away you’ve done something wrong.
To me, the power of Svelte is that it doesn’t “help” any more than I need it to.
Thinking about it there is already a similar syntax that i think would solve the issue but it does not work on slots. But if you could get a reference to the slot it would open a lot of doors