1 parent 12dcb64 commit 79898cfCopy full SHA for 79898cf
1 file changed
src/routes/(0)concepts/(2)signals.mdx
@@ -72,6 +72,17 @@ setCount((prevCount) => prevCount + 1);
72
console.log(count()); // output: 1
73
```
74
75
+When a signal contains an object or array, mutating it directly does not notify subscribers because the setter was not called.
76
+Use the setter to create a new object or array instead:
77
+
78
+```jsx
79
+const [items, setItems] = createSignal(["apple", "banana"]);
80
81
+setItems((currentItems) => [...currentItems, "cherry"]);
82
+```
83
84
+For state that requires frequent nested updates, consider using a [store](/concepts/stores) instead.
85
86
## Reactivity
87
88
Signals are reactive, which means that they automatically update when their value changes.
0 commit comments