Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 467 Bytes

use-reset-atom.mdx

File metadata and controls

23 lines (18 loc) · 467 Bytes
title
useResetAtom
function useResetAtom<Value>(
  anAtom: WritableAtom<Value, typeof RESET>
): () => void | Promise<void>

Resets a Resettable atom to its initial value.

Example

import { useResetAtom } from 'jotai/utils'
import { todoListAtom } from './store'

const TodoResetButton = () => {
  const resetTodoList = useResetAtom(todoListAtom)
  return <button onClick={resetTodoList}>Reset</button>
}