Skip to content

Commit ecd475a

Browse files
brenelzatilafassinaLadyBluenoteskodiakhq[bot]
authored
document setter function passing previous value (#961)
Co-authored-by: Atila Fassina <[email protected]> Co-authored-by: Sarah <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 5f13526 commit ecd475a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/routes/concepts/signals.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ setCount(count() + 1);
4949
console.log(count()); // output: 1
5050
```
5151

52+
The setter function can also take a function that passes the previous value.
53+
54+
```jsx
55+
setCount((prevCount) => prevCount + 1);
56+
57+
console.log(count()); // output: 1
58+
```
59+
5260
## Reactivity
5361

5462
Signals are reactive, which means that they automatically update when their value changes.

0 commit comments

Comments
 (0)