mirror of
https://github.com/get-drexa/drive.git
synced 2025-12-01 05:51:39 +00:00
refactor: migrate to vite and restructure repo
Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
15
apps/drive-web/src/components/with-atom.tsx
Normal file
15
apps/drive-web/src/components/with-atom.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user