Skip to content

Commit a471518

Browse files
Sync svelte docs (#1630)
sync svelte docs Co-authored-by: svelte-docs-bot[bot] <196124396+svelte-docs-bot[bot]@users.noreply.github.com>
1 parent 1aadc73 commit a471518

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

apps/svelte.dev/content/docs/svelte/02-runes/07-$inspect.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ The `$inspect` rune is roughly equivalent to `console.log`, with the exception t
1919
<input bind:value={message} />
2020
```
2121

22+
On updates, a stack trace will be printed, making it easy to find the origin of a state change (unless you're in the playground, due to technical limitations).
23+
2224
## $inspect(...).with
2325

2426
`$inspect` returns a property `with`, which you can invoke with a callback, which will then be invoked instead of `console.log`. The first argument to the callback is either `"init"` or `"update"`; subsequent arguments are the values passed to `$inspect` ([demo](/playground/untitled#H4sIAAAAAAAACkVQ24qDMBD9lSEUqlTqPlsj7ON-w7pQG8c2VCchmVSK-O-bKMs-DefKYRYx6BG9qL4XQd2EohKf1opC8Nsm4F84MkbsTXAqMbVXTltuWmp5RAZlAjFIOHjuGLOP_BKVqB00eYuKs82Qn2fNjyxLtcWeyUE2sCRry3qATQIpJRyD7WPVMf9TW-7xFu53dBcoSzAOrsqQNyOe2XUKr0Xi5kcMvdDB2wSYO-I9vKazplV1-T-d6ltgNgSG1KjVUy7ZtmdbdjqtzRcphxMS1-XubOITJtPrQWMvKnYB15_1F7KKadA_AQAA)):
@@ -37,13 +39,6 @@ The `$inspect` rune is roughly equivalent to `console.log`, with the exception t
3739
<button onclick={() => count++}>Increment</button>
3840
```
3941

40-
A convenient way to find the origin of some change is to pass `console.trace` to `with`:
41-
42-
```js
43-
// @errors: 2304
44-
$inspect(stuff).with(console.trace);
45-
```
46-
4742
## $inspect.trace(...)
4843

4944
This rune, added in 5.14, causes the surrounding function to be _traced_ in development. Any time the function re-runs as part of an [effect]($effect) or a [derived]($derived), information will be printed to the console about which pieces of reactive state caused the effect to fire.

0 commit comments

Comments
 (0)