Skip to content

Commit 0ec8710

Browse files
authored
Update 05-$props.md
1 parent 557b45b commit 0ec8710

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

documentation/docs/02-runes/05-$props.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,21 @@ References to a prop inside a component update when the prop itself updates —
9292
</button>
9393
```
9494

95-
Prop variables not automatically deeply reactive. If a prop value is an object, setting a property of that object will not cause the component to update ([demo](/playground/untitled#H4sIAAAAAAAAE3VPS07DMBC9yshCaiuqBLYhjoQ4Q1eEReJOVIMztuJJBbJ8d-IkEqXQ5bx53yCo6VEU4kCs2eBR7EWnDXpRvAbBXy79EjDhK_PZucyf0XDC2sbjf7iyxEg82YjSq0E7rmqqWffODgwvJ22O0A22h02Wz9cq3TzVVOY_CioXrm3fUbEMQdmRuICHGCGvpiDGTxYFDyPG_Y3Cl_6_K199bpQ2yBDWBhBBwp0brPPb3Z-u7chsCSwpo9WHDNsdyApCMslzODUeyAJ23WSUsMUymyfBvYTHmmKcI2e9LyBcUmKKWyKulr_Fb2Z_SHPIAQAA)):
95+
Prop variables are not automatically deeply reactive. What happens when mutating one of their properties depends on what the parent passed in. For example if the parent passed a non-reactive POJO as a prop, setting a property of that object in the child will not cause the component to update ([demo](/playground/untitled#H4sIAAAAAAAAE3VPS07DMBC9yshCaiuqBLYhjoQ4Q1eEReJOVIMztuJJBbJ8d-IkEqXQ5bx53yCo6VEU4kCs2eBR7EWnDXpRvAbBXy79EjDhK_PZucyf0XDC2sbjf7iyxEg82YjSq0E7rmqqWffODgwvJ22O0A22h02Wz9cq3TzVVOY_CioXrm3fUbEMQdmRuICHGCGvpiDGTxYFDyPG_Y3Cl_6_K199bpQ2yBDWBhBBwp0brPPb3Z-u7chsCSwpo9WHDNsdyApCMslzODUeyAJ23WSUsMUymyfBvYTHmmKcI2e9LyBcUmKKWyKulr_Fb2Z_SHPIAQAA)):
9696

97+
```svelte
98+
<--- file: App.svelte --->
99+
<script>
100+
import Child from './Child.svelte';
101+
102+
let object = $state({count: 0});
103+
</script>
104+
105+
<Child {object} />
106+
```
97107

98-
<!-- prettier-ignore -->
99108
```svelte
100-
/// file: Child.svelte
109+
<--- file: Child.svelte --->
101110
<script>
102111
let { object } = $props();
103112
</script>
@@ -110,12 +119,10 @@ Prop variables not automatically deeply reactive. If a prop value is an object,
110119
</button>
111120
```
112121

113-
However if the value passed in by the parent component is itself a deeply reactive state object, then it will be deeply reactive in the child too ([demo](/playground/untitled#H4sIAAAAAAAAE3WQwU7DMBBEf2VlITUVVQLXkERC_YaeCIfE2aoujm3FGwqy_O_YcSug0KNnx7Nv1jHVjchKtlMkSOLANmwvJFpWvjhGnybOohD0s_PZmNy-o6So9Z3F_3SuFaGiEMMqyydhqGlVS2I0eiLYHoQcYD_pEVZ5sbzOX1dPwRaMEgl0f0ROUMOdpY4wc1zPikp48OvgqorvXFWlRJe-eCiawED4QaykaUa_udHl5-rfba4mN_pETHcB9RHVTNrY7C9gPxNpBVpxKfhb7bI11A24GFIUcBJSAu9mi0AHhKUo9Cj1CUjDbIbQP1rTpjzN72t4bJX3C8kSa8vLCZLFR4q0-eogr_4LN7sC9foBAAA=)):
114-
122+
However if the value passed in by the parent component is itself a deeply reactive state object, then it will be deeply reactive in the child, too ([demo](/playground/untitled#H4sIAAAAAAAAE3WQwU7DMBBEf2VlITUVVQLXkERC_YaeCIfE2aoujm3FGwqy_O_YcSug0KNnx7Nv1jHVjchKtlMkSOLANmwvJFpWvjhGnybOohD0s_PZmNy-o6So9Z3F_3SuFaGiEMMqyydhqGlVS2I0eiLYHoQcYD_pEVZ5sbzOX1dPwRaMEgl0f0ROUMOdpY4wc1zPikp48OvgqorvXFWlRJe-eCiawED4QaykaUa_udHl5-rfba4mN_pETHcB9RHVTNrY7C9gPxNpBVpxKfhb7bI11A24GFIUcBJSAu9mi0AHhKUo9Cj1CUjDbIbQP1rTpjzN72t4bJX3C8kSa8vLCZLFR4q0-eogr_4LN7sC9foBAAA=)):
115123

116-
<!-- prettier-ignore -->
117124
```svelte
118-
/// file: App.svelte
125+
<--- file: App.svelte --->
119126
<script>
120127
import Child from './Child.svelte';
121128
@@ -125,9 +132,8 @@ However if the value passed in by the parent component is itself a deeply reacti
125132
<Child {object} />
126133
```
127134

128-
<!-- prettier-ignore -->
129135
```svelte
130-
/// file: Child.svelte
136+
<--- file: Child.svelte --->
131137
<script>
132138
let { object } = $props();
133139
</script>

0 commit comments

Comments
 (0)