javascript / beginner
Snippet
Declaring Component Props
In Svelte, props are declared using the `export` keyword. This makes the variable accessible to parent components so they can pass data down. You can also provide a default value in case the prop isn't supplied.
snippet.js
1
2
3
4
5
<script>export let title = 'Default Title';</script><h1>{title}</h1>
svelte
Breakdown
1
export let title = ...
The 'export' keyword turns a local variable into a component property (prop).