0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-25 00:51:01 +01:00
svelte/documentation/tutorial/03-props/01-declaring-props/text.md

16 lines
652 B
Markdown
Raw Permalink Normal View History

2019-03-10 14:30:29 +01:00
---
title: Declaring props
---
So far, we've dealt exclusively with internal state — that is to say, the values are only accessible within a given component.
In any real application, you'll need to pass data from one component down to its children. To do that, we need to declare _properties_, generally shortened to 'props'. In Svelte, we do that with the `export` keyword. Edit the `Nested.svelte` component:
2019-03-10 14:30:29 +01:00
```svelte
2019-03-10 14:30:29 +01:00
<script>
export let answer;
</script>
```
> Just like `$:`, this may feel a little weird at first. That's not how `export` normally works in JavaScript modules! Just roll with it for now — it'll soon become second nature.