mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-21 06:34:30 +01:00
Added jotai (#14)
* Added jotai * cache settings by using jotai state * use hydrateAtom with SSR * remove useSettings * fix test
This commit is contained in:
16
components/jotai-hydrate.tsx
Normal file
16
components/jotai-hydrate.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
'use client'
|
||||
|
||||
import { settingsAtom } from "@/lib/atoms"
|
||||
import { useHydrateAtoms } from "jotai/utils"
|
||||
import { Settings } from "@/lib/types"
|
||||
|
||||
export function JotaiHydrate({
|
||||
children,
|
||||
initialSettings
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
initialSettings: Settings
|
||||
}) {
|
||||
useHydrateAtoms([[settingsAtom, initialSettings]])
|
||||
return children
|
||||
}
|
||||
Reference in New Issue
Block a user