Moar debug

This commit is contained in:
Eric Bailey
2025-08-11 14:27:49 -05:00
parent 09444add21
commit 2d9c0edbd4
+10 -3
View File
@@ -113,14 +113,21 @@ export function useStorage<
] { ] {
type Schema = StorageSchema<Store> type Schema = StorageSchema<Store>
const initialized = useRef(false) const initialized = useRef(false)
const [value, setValue] = useState<Schema[Key] | undefined>(() => const [value, setValue] = useState<Schema[Key] | undefined>(() => {
storage.get(scopes), if (debug) logger.debug(`${debug} - init`, {
) value: storage.get(scopes) ?? 'unset'
})
return storage.get(scopes)
})
useEffect(() => { useEffect(() => {
if (!initialized.current) { if (!initialized.current) {
const raw = storage.get(scopes) const raw = storage.get(scopes)
if (value !== raw) { if (value !== raw) {
logger.debug(`${debug} - syncing initial`, {
value: value ?? 'unset',
raw: raw ?? 'unset',
})
initialized.current = true initialized.current = true
setValue(raw) setValue(raw)
} }