Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/routes/(0)concepts/(2)signals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ setCount((prevCount) => prevCount + 1);
console.log(count()); // output: 1
```

When a signal contains an object or array, mutating it directly does not notify subscribers because the setter was not called.
Use the setter to create a new object or array instead:

```jsx
const [items, setItems] = createSignal(["apple", "banana"]);

setItems((currentItems) => [...currentItems, "cherry"]);
```

For state that requires frequent nested updates, consider using a [store](/concepts/stores) instead.

## Reactivity

Signals are reactive, which means that they automatically update when their value changes.
Expand Down
Loading