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