atomWithReset
Ref: https://github.com/pmndrs/jotai/issues/41
function atomWithReset<Value>(initialValue: Value): WritableAtom<Value, SetStateAction<Value> | typeof RESET>
Creates an atom that could be reset to its initialValue
with
useResetAtom
hook. It works exactly the same
way as primitive atom would, but you are also able to set it to a special value
RESET
. See examples in Resettable atoms.
Example
import { atomWithReset } from 'jotai/utils'const dollarsAtom = atomWithReset(0)const todoListAtom = atomWithReset([{ description: 'Add a todo', checked: false }])