useResetAtom is a utility hook that returns a function to reset an atom to its initial value. It uses the special RESET symbol internally.
When to use it
UseuseResetAtom when you need to reset an atom back to its default/initial value without knowing what that value is.
Signature
Parameters
anAtom: A writable atom that supports the RESET symboloptions: Optional configuration objectstore: Custom store to use (defaults to the store from Provider)
Returns
A stable function that resets the atom when called.Basic Usage
With atomWithReset
For primitive atoms, useatomWithReset to enable reset functionality:
With Custom Write Logic
You can implement custom reset behavior in your atom:Resetting Multiple Atoms
You can create a custom hook to reset multiple related atoms:Comparison with Direct Setting
TypeScript
useResetAtom works with properly typed atoms: