createSetAtom

Signature
createSetAtom<T>(atom: Atom<T>): SetterFn<T>

valdres-solid Write-only access to an atom

Returns a setter function for an atom without subscribing to changes. The component won't re-render when the atom updates.

Usage

import { atom } from "valdres"
import { createSetAtom } from "valdres-solid"

const countAtom = atom(0)

function IncrementButton() {
    const setCount = createSetAtom(countAtom)
    return <button onClick={() => setCount(c => c + 1)}>+</button>
}

See also