- Addresses a compatibility issue with [email protected] that caused atomEffects to lose their dependencies during recomputations.
- Introduces a new utility helper
withAtomEffect
Usage
const anAtom = atom(0)
// the effect is automatically added to the resulting atom
// setting the resulting atom is forwarded to the atom passed in
const anAtomWithEffect = withAtomEffect(anAtom, (get, set) => {
console.log(`anAtom value is now ${get(anAtom)}`)
})
...
const [value, setValue] = useAtom(anAtomWithEffect)