Files
drive/apps/drive-web/src/components/with-atom.tsx

16 lines
337 B
TypeScript
Raw Normal View History

import { type PrimitiveAtom, useAtom } from "jotai"
export function WithAtom<Value>({
atom,
children,
}: {
atom: PrimitiveAtom<Value>
children: (
value: Value,
2025-10-12 00:43:31 +00:00
setValue: (value: Value | ((current: Value) => Value)) => void,
) => React.ReactNode
}) {
const [value, setValue] = useAtom(atom)
return children(value, setValue)
}