Skip to content

Commit d6abd0a

Browse files
authored
docs: clarify performance concerns around props and restProps (#9047)
* docs: clarify performance concerns around props and restProps * Update documentation/docs/02-template-syntax/02-basic-markup.md
1 parent 01cbb66 commit d6abd0a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

documentation/docs/02-template-syntax/02-basic-markup.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ An element or component can have multiple spread attributes, interspersed with r
8585
<Widget {...things} />
8686
```
8787

88-
`$$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.
88+
`$$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.
8989

9090
```svelte
9191
<Widget {...$$props} />
9292
```
9393

94-
`$$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.
94+
`$$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`.
9595

9696
```svelte
9797
<input {...$$restProps} />

0 commit comments

Comments
 (0)