Skip to content

Commit 429af4e

Browse files
authored
fix runtime-warnings page (#742)
* fix runtime-warnings page * fix
1 parent e78cb03 commit 429af4e

File tree

1 file changed

+46
-77
lines changed

1 file changed

+46
-77
lines changed

apps/svelte.dev/content/docs/svelte/98-reference/30-runtime-warnings.md

Lines changed: 46 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,162 +2,131 @@
22
title: 'Runtime warnings'
33
---
44

5-
## Client errors
5+
## Client warnings
66

7-
### bind_invalid_checkbox_value
7+
### binding_property_non_reactive
88

99
```
10-
Using `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead
10+
`%binding%` is binding to a non-reactive property
1111
```
1212

13-
### bind_invalid_export
14-
15-
```
16-
Component %component% has an export named `%key%` that a consumer component is trying to access using `bind:%key%`, which is disallowed. Instead, use `bind:this` (e.g. `<%name% bind:this={component} />`) and then access the property on the bound component instance (e.g. `component.%key%`)
17-
```
18-
19-
### bind_not_bindable
20-
2113
```
22-
A component is attempting to bind to a non-bindable property `%key%` belonging to %component% (i.e. `<%name% bind:%key%={...}>`). To mark a property as bindable: `let { %key% = $bindable() } = $props()`
14+
`%binding%` (%location%) is binding to a non-reactive property
2315
```
2416

25-
### component_api_changed
17+
### console_log_state
2618

2719
```
28-
%parent% called `%method%` on an instance of %component%, which is no longer valid in Svelte 5. See https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes for more information
20+
Your `console.%method%` contained `$state` proxies. Consider using `$inspect(...)` or `$state.snapshot(...)` instead
2921
```
3022

31-
### component_api_invalid_new
23+
When logging a [proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), browser devtools will log the proxy itself rather than the value it represents. In the case of Svelte, the 'target' of a `$state` proxy might not resemble its current value, which can be confusing.
3224

33-
```
34-
Attempted to instantiate %component% with `new %name%`, which is no longer valid in Svelte 5. If this component is not under your control, set the `compatibility.componentApi` compiler option to `4` to keep it working. See https://svelte.dev/docs/svelte/v5-migration-guide#Components-are-no-longer-classes for more information
35-
```
25+
The easiest way to log a value as it changes over time is to use the [`$inspect`](https://svelte.dev/docs/svelte/$inspect) rune. Alternatively, to log things on a one-off basis (for example, inside an event handler) you can use [`$state.snapshot`](https://svelte.dev/docs/svelte/$state#$state.snapshot) to take a snapshot of the current value.
3626

37-
### derived_references_self
27+
### event_handler_invalid
3828

3929
```
40-
A derived value cannot reference itself recursively
30+
%handler% should be a function. Did you mean to %suggestion%?
4131
```
4232

43-
### each_key_duplicate
44-
45-
```
46-
Keyed each block has duplicate key at indexes %a% and %b%
47-
```
33+
### hydration_attribute_changed
4834

4935
```
50-
Keyed each block has duplicate key `%value%` at indexes %a% and %b%
36+
The `%attribute%` attribute on `%html%` changed its value between server and client renders. The client value, `%value%`, will be ignored in favour of the server value
5137
```
5238

53-
### effect_in_teardown
39+
### hydration_html_changed
5440

5541
```
56-
`%rune%` cannot be used inside an effect cleanup function
42+
The value of an `{@html ...}` block changed between server and client renders. The client value will be ignored in favour of the server value
5743
```
5844

59-
### effect_in_unowned_derived
60-
6145
```
62-
Effect cannot be created inside a `$derived` value that was not itself created inside an effect
46+
The value of an `{@html ...}` block %location% changed between server and client renders. The client value will be ignored in favour of the server value
6347
```
6448

65-
### effect_orphan
49+
### hydration_mismatch
6650

6751
```
68-
`%rune%` can only be used inside an effect (e.g. during component initialisation)
52+
Hydration failed because the initial UI does not match what was rendered on the server
6953
```
7054

71-
### effect_update_depth_exceeded
72-
7355
```
74-
Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops
56+
Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near %location%
7557
```
7658

77-
### hydration_failed
59+
### invalid_raw_snippet_render
7860

7961
```
80-
Failed to hydrate the application
62+
The `render` function passed to `createRawSnippet` should return HTML for a single element
8163
```
8264

83-
### invalid_snippet
65+
### legacy_recursive_reactive_block
8466

8567
```
86-
Could not `{@render}` snippet due to the expression being `null` or `undefined`. Consider using optional chaining `{@render snippet?.()}`
68+
Detected a migrated `$:` reactive block in `%filename%` that both accesses and updates the same reactive value. This may cause recursive updates when converted to an `$effect`.
8769
```
8870

89-
### lifecycle_legacy_only
71+
### lifecycle_double_unmount
9072

9173
```
92-
`%name%(...)` cannot be used in runes mode
74+
Tried to unmount a component that was not mounted
9375
```
9476

95-
### props_invalid_value
77+
### ownership_invalid_binding
9678

9779
```
98-
Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value
80+
%parent% passed a value to %child% with `bind:`, but the value is owned by %owner%. Consider creating a binding between %owner% and %parent%
9981
```
10082

101-
### props_rest_readonly
83+
### ownership_invalid_mutation
10284

10385
```
104-
Rest element properties of `$props()` such as `%property%` are readonly
86+
Mutating a value outside the component that created it is strongly discouraged. Consider passing values to child components with `bind:`, or use a callback instead
10587
```
10688

107-
### rune_outside_svelte
108-
10989
```
110-
The `%rune%` rune is only available inside `.svelte` and `.svelte.js/ts` files
90+
%component% mutated a value owned by %owner%. This is strongly discouraged. Consider passing values to child components with `bind:`, or use a callback instead
11191
```
11292

113-
### state_descriptors_fixed
93+
### state_proxy_equality_mismatch
11494

11595
```
116-
Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
96+
Reactive `$state(...)` proxies and the values they proxy have different identities. Because of this, comparisons with `%operator%` will produce unexpected results
11797
```
11898

119-
### state_prototype_fixed
120-
121-
```
122-
Cannot set prototype of `$state` object
123-
```
99+
`$state(...)` creates a [proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) of the value it is passed. The proxy and the value have different identities, meaning equality checks will always return `false`:
124100

125-
### state_unsafe_local_read
101+
```svelte
102+
<script>
103+
let value = { foo: 'bar' };
104+
let proxy = $state(value);
126105
106+
value === proxy; // always false
107+
</script>
127108
```
128-
Reading state that was created inside the same derived is forbidden. Consider using `untrack` to read locally created state
129-
```
130-
131-
### state_unsafe_mutation
132109

133-
```
134-
Updating state inside a derived or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
135-
```
110+
To resolve this, ensure you're comparing values where both values were created with `$state(...)`, or neither were. Note that `$state.raw(...)` will _not_ create a state proxy.
136111

137112

138-
## Shared errors
113+
## Shared warnings
139114

140-
### invalid_default_snippet
115+
### dynamic_void_element_content
141116

142117
```
143-
Cannot use `{@render children(...)}` if the parent component uses `let:` directives. Consider using a named snippet instead
118+
`<svelte:element this="%tag%">` is a void element — it cannot have content
144119
```
145120

146-
### lifecycle_outside_component
121+
### state_snapshot_uncloneable
147122

148123
```
149-
`%name%(...)` can only be used during component initialisation
124+
Value cannot be cloned with `$state.snapshot` — the original value was returned
150125
```
151126

152-
### store_invalid_shape
153-
154127
```
155-
`%name%` is not a store with a `subscribe` method
156-
```
157-
158-
### svelte_element_invalid_this_value
128+
The following properties cannot be cloned with `$state.snapshot` — the return value contains the originals:
159129
160-
```
161-
The `this` prop on `<svelte:element>` must be a string, if defined
130+
%properties%
162131
```
163132

0 commit comments

Comments
 (0)