diff --git a/src/storage/index.ts b/src/storage/index.ts index d503167ae7..f4d81c59ea 100644 --- a/src/storage/index.ts +++ b/src/storage/index.ts @@ -113,14 +113,21 @@ export function useStorage< ] { type Schema = StorageSchema const initialized = useRef(false) - const [value, setValue] = useState(() => - storage.get(scopes), - ) + const [value, setValue] = useState(() => { + if (debug) logger.debug(`${debug} - init`, { + value: storage.get(scopes) ?? 'unset' + }) + return storage.get(scopes) + }) useEffect(() => { if (!initialized.current) { const raw = storage.get(scopes) if (value !== raw) { + logger.debug(`${debug} - syncing initial`, { + value: value ?? 'unset', + raw: raw ?? 'unset', + }) initialized.current = true setValue(raw) }