useResetAtom
function useResetAtom<Value>(anAtom: WritableAtom<Value, typeof RESET>): () => void | Promise<void>;
将 Resettable atom 重置为其初始值。
示例
import { useResetAtom } from "jotai/utils";import { todoListAtom } from "./store";const TodoResetButton = () => {const resetTodoList = useResetAtom(todoListAtom);return <button onClick={resetTodoList}>Reset</button>;};