Part 1 / Props / Default values
We can easily specify default values for props in Nested.svelte
:
Nested.svelte
<script>
export let answer = 'a mystery';
</script>
If we now add a second component without an answer
prop, it will fall back to the default:
App.svelte
<Nested answer={42}/>
<Nested />
1
2
3
4
5
6
<script>
import Nested from './Nested.svelte';
</script>
<Nested answer={42} />
initialising