Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/jotai/docs/utils/atom-with-reset.mdx

👻 Primitive and flexible state management for React
Go to Latest
File
---title: atomWithReset---
Ref: https://github.com/pmndrs/jotai/issues/41
```tsfunction atomWithReset<Value>( initialValue: Value): WritableAtom<Value, SetStateAction<Value> | typeof RESET>```
Creates an atom that could be reset to its `initialValue` with[`useResetAtom`](use-reset-atom.mdx) hook. It works exactly the sameway as primitive atom would, but you are also able to set it to a special value[`RESET`](reset.mdx). See examples in [Resettable atoms](../guides/resettable.mdx).
## Example
```jsimport { atomWithReset } from 'jotai/utils'
const dollarsAtom = atomWithReset(0)const todoListAtom = atomWithReset([ { description: 'Add a todo', checked: false },])```