Skip to content

Commit

Permalink
docs: clarify performance concerns around props and restProps (#9047)
Browse files Browse the repository at this point in the history
* docs: clarify performance concerns around props and restProps

* Update documentation/docs/02-template-syntax/02-basic-markup.md
  • Loading branch information
benmccann committed Jul 27, 2023
1 parent 01cbb66 commit d6abd0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions documentation/docs/02-template-syntax/02-basic-markup.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ An element or component can have multiple spread attributes, interspersed with r
<Widget {...things} />
```

`$$props` references all props that are passed to a component, including ones that are not declared with `export`. It is not generally recommended, as it is difficult for Svelte to optimise. But it can be useful in rare cases – for example, when you don't know at compile time what props might be passed to a component.
`$$props` references all props that are passed to a component, including ones that are not declared with `export`. Using `$$props` will not perform as well as references to a specific prop because changes to any prop will cause Svelte to recheck all usages of `$$props`. But it can be useful in some cases – for example, when you don't know at compile time what props might be passed to a component.

```svelte
<Widget {...$$props} />
```

`$$restProps` contains only the props which are _not_ declared with `export`. It can be used to pass down other unknown attributes to an element in a component. It shares the same optimisation problems as `$$props`, and is likewise not recommended.
`$$restProps` contains only the props which are _not_ declared with `export`. It can be used to pass down other unknown attributes to an element in a component. It shares the same performance characteristics compared to specific property access as `$$props`.

```svelte
<input {...$$restProps} />
Expand Down

0 comments on commit d6abd0a

Please sign in to comment.