chore: remove $state.is from docs (#12927)

pull/12931/head
Dominic Gannaway 1 year ago committed by GitHub
parent 44a780fb9c
commit a8c6b92f9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -118,7 +118,6 @@ const runes = [
{ snippet: '$bindable()', test: is_bindable },
{ snippet: '$effect.root(() => {\n\t${}\n})' },
{ snippet: '$state.snapshot(${})' },
{ snippet: '$state.is(${})' },
{ snippet: '$effect.tracking()' },
{ snippet: '$inspect(${});', test: is_statement }
];

@ -108,26 +108,6 @@ To take a static snapshot of a deeply reactive `$state` proxy, use `$state.snaps
This is handy when you want to pass some state to an external library or API that doesn't expect a proxy, such as `structuredClone`.
## `$state.is`
Sometimes you might need to compare two values, one of which is a reactive `$state(...)` proxy. For this you can use `$state.is(a, b)`:
```svelte
<script>
let foo = $state({});
let bar = {};
foo.bar = bar;
console.log(foo.bar === bar); // false — `foo.bar` is a reactive proxy
console.log($state.is(foo.bar, bar)); // true
</script>
```
This is handy when you might want to check if the object exists within a deeply reactive object/array.
> `$state.is` uses `Object.is` to check if two values are the same value.
## `$derived`
Derived state is declared with the `$derived` rune:

Loading…
Cancel
Save