useSetAtom
Signature
useSetAtom<T>(atom: Atom<T>): SetterFn<T>valdres-vue Write-only access to an atom
Returns a setter function for an atom without subscribing to its value. Use this when a component only needs to trigger updates.
Usage
<script setup>
import { atom } from "valdres"
import { useSetAtom } from "valdres-vue"
const countAtom = atom(0)
const setCount = useSetAtom(countAtom)
</script>
<template>
<button @click="setCount(c => c + 1)">+</button>
</template>
See also
- useAtom — read + write composable
- useResetAtom — reset to default value