Skip to main content
Module

x/jotai/docs/utils/freeze-atom.mdx

👻 Primitive and flexible state management for React
Go to Latest
File
---title: freezeAtom---
## Usage
```tsfreezeAtom(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 triedto change objects (states) which can lead to unexpected behavior.You may use `freezeAtom` with all atoms to prevent this situation.
## Parameters
**anAtom** (required): An atom you wish to freeze.
## Examples
```jsimport { atom } from 'jotai'import { freezeAtom } from 'jotai/utils'
const objAtom = freezeAtom(atom({ count: 0 }))```
## CodeSandbox