Skip to content

Commit

Permalink
document setter function passing previous value (#961)
Browse files Browse the repository at this point in the history
Co-authored-by: Atila Fassina <atilafassina@gmail.com>
Co-authored-by: Sarah <gerrardsarah@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 26, 2024
1 parent 5f13526 commit ecd475a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/routes/concepts/signals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ setCount(count() + 1);
console.log(count()); // output: 1
```

The setter function can also take a function that passes the previous value.

```jsx
setCount((prevCount) => prevCount + 1);

console.log(count()); // output: 1
```

## Reactivity

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

0 comments on commit ecd475a

Please sign in to comment.