Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<ComponentName> was created without expected prop 'segment'

Tags:

svelte

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'
like image 809
piecioshka Avatar asked Oct 26 '19 14:10

piecioshka


1 Answers

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.

like image 180
Rich Harris Avatar answered Nov 15 '22 07:11

Rich Harris