mirror of
https://github.com/get-drexa/drive.git
synced 2025-11-30 21:41:39 +00:00
16 lines
337 B
TypeScript
16 lines
337 B
TypeScript
import { type PrimitiveAtom, useAtom } from "jotai"
|
|
|
|
export function WithAtom<Value>({
|
|
atom,
|
|
children,
|
|
}: {
|
|
atom: PrimitiveAtom<Value>
|
|
children: (
|
|
value: Value,
|
|
setValue: (value: Value | ((current: Value) => Value)) => void,
|
|
) => React.ReactNode
|
|
}) {
|
|
const [value, setValue] = useAtom(atom)
|
|
return children(value, setValue)
|
|
}
|