Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 457 Bytes

freeze-atom-creator.mdx

File metadata and controls

15 lines (12 loc) · 457 Bytes
title
freezeAtomCreator
import { atom } from 'jotai'
import { freezeAtomCreator } from 'jotai/utils'

const createFrozenAtom = freezeAtomCreator(atom)
const objAtom = createFrozenAtom({ count: 0 })

Instead of create a frozen atom from an existing atom, freezeAtomCreator takes an atom creator function and returns a new function. You can use this not only for atom, but also for other atomWith* creators such as atomWithReduer.