title |
---|
freezeAtom |
freezeAtom(anAtom): AtomType
freezeAtom
takes an existing atom and returns a new derived "frozen" atom.
The atom will be deeply frozen by Object.freeze
.
It is useful to find bugs where you unintentionally tried
to change objects (states) which can lead to unexpected behavior.
You may use freezeAtom
with all atoms to prevent this situation.
anAtom (required): An atom you wish to freeze.
import { atom } from 'jotai'
import { freezeAtom } from 'jotai/utils'
const objAtom = freezeAtom(atom({ count: 0 }))