UNPKG

jotai

Version:

👻 Primitive and flexible state management for React

9 lines (8 loc) • 338 B
'use client'; import { useMemo } from 'react'; import { useSetAtom } from '../../react.js'; import { atom } from '../../vanilla.js'; export function useAtomCallback(callback, options) { const anAtom = useMemo(() => atom(null, (get, set, ...args) => callback(get, set, ...args)), [callback]); return useSetAtom(anAtom, options); }