[note] jotai 筆記
- utils @ jot > api
TL;DR
import { atom, useAtom, useAtomValue } from 'jotai';
import { useAtomValue, useUpdateAtom } from 'jotai/utils'
const isEditingAtom = atom(false);
const App = () => {
// normal usage
const [isEditing, setIsEditing] = useAtom(countAtom)
// if only need the setter
// useUpdateAtom can prevent unnecessary re-render
const setIsEditing = useUpdateAtom(isEditingAtom);
// if only need the getter
const isEditing = useAtomValue(isEditingAtom);
}