2
0
Эх сурвалжийг харах

Set fallbackData as option of useEditorSettings

Taichi Masuyama 3 жил өмнө
parent
commit
2ebd64e685

+ 4 - 1
packages/app/src/stores/editor.tsx

@@ -27,7 +27,10 @@ export const useEditorSettings = (): SWRResponseWithUtils<EditorSettingsOperatio
   const swrResult = useSWRImmutable<IEditorSettings>(
     isGuestUser ? null : ['/personal-setting/editor-settings', currentUser?.username],
     endpoint => apiv3Get(endpoint).then(result => result.data),
-    { use: [localStorageMiddleware] }, // store to localStorage for initialization fastly
+    {
+      use: [localStorageMiddleware], // store to localStorage for initialization fastly
+      fallbackData: undefined,
+    },
   );
 
   return withUtils<EditorSettingsOperation, IEditorSettings, Error>(swrResult, {

+ 1 - 1
packages/app/src/stores/middlewares/sync-to-storage.ts

@@ -34,8 +34,8 @@ export const createSyncToStorageMiddlware = (
       }
 
       const swrNext = useSWRNext(key, fetcher, {
-        fallbackData: initData,
         ...config,
+        fallbackData: initData,
       });
 
       return {