When you create empty Svelte component (eg. ComponentName.svelte
) like this:
<script>
export let segment;
</script>
<style>
</style>
<svelte:head>
<title>Lorem ipsum</title>
</svelte:head>
<p>lorem ipsum...</p>
you will have error:
<ComponentName> was created without expected prop 'segment'
This is to help you debug — you've defined a segment
prop, but the consumer of the component isn't giving it a value, which is likely to be the cause of bugs. Either the consumer should provide a value — <ComponentName segment="foo"/>
— or you should a) remove the prop, or b) give it a default value (which can be undefined
):
export let segment = undefined;
Any of those three actions will prevent the warning from appearing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With