Skip to main content
Module

x/jotai/docs/utils/reset.mdx

👻 Primitive and flexible state management for React
Go to Latest
File
---title: RESET---
Ref: https://github.com/pmndrs/jotai/issues/217
```tsconst RESET: unique symbol```
Special value that is accepted by [Resettable atoms](../guides/resettable.mdx)created with [`atomWithReset`](atom-with-reset.mdx), [`atomWithDefault`](atom-with-default.mdx)or writable atom created with `atom` if it accepts `RESET` symbol.
## Example
```jsximport { atom } from 'jotai'import { atomWithReset, useResetAtom, RESET } from 'jotai/utils'
const dollarsAtom = atomWithReset(0)const centsAtom = atom( (get) => get(dollarsAtom) * 100, (get, set, newValue: number | typeof RESET) => set(dollarsAtom, newValue === RESET ? newValue : newValue / 100))
const ResetExample = () => { const setDollars = useUpdateAtom(dollarsAtom) const resetCents = useResetAtom(centsAtom) return ( <> <button onClick={() => setDollars(RESET)}>Reset dollars</button> <button onClick={resetCents}>Reset cents</button> </> )}```