useAtomCallback
Creates imperative callbacks that can read and write atom values without causing component re-renders.Import
Signature
Parameters
A callback function that receives:
get: Function to read atom valuesset: Function to write atom values...arg: Additional arguments passed when the callback is invoked
Optional configuration:
store: Specify a custom store to use
Returns
Returns a memoized callback function that can be called with the specified arguments. Type:(...args: Args) => Result
Usage
Async Callbacks
With Arguments
Reading Without Re-renders
useAtomCallback is useful when you need to read atom values imperatively without subscribing to updates:
Related APIs
- useSetAtom - Write atoms without subscribing to updates
- useAtomValue - Read atoms with subscriptions
- atom - Create atoms with custom read/write logic