Просмотр исходного кода

update useSWRStatic data with mutate method

Yuki Takei 2 лет назад
Родитель
Сommit
bf0ba232a1

+ 2 - 2
packages/core/src/swr/use-swr-static.ts

@@ -28,9 +28,9 @@ export function useSWRStatic<Data, Error>(
     ),
     ),
   });
   });
 
 
-  // write data to cache directly
+  // update data
   if (key != null && data !== undefined) {
   if (key != null && data !== undefined) {
-    cache.set(key.toString(), { ...cache.get(key.toString()), data });
+    swrResponse.mutate(data, { optimisticData: data });
   }
   }
 
 
   return swrResponse;
   return swrResponse;

+ 0 - 5
packages/editor/src/services/codemirror-editor/use-codemirror-editor/use-codemirror-editor.ts

@@ -47,11 +47,6 @@ export const useCodeMirrorEditor = (props?: UseCodeMirror): UseCodeMirrorEditor
   const focus = useFocus(view);
   const focus = useFocus(view);
   const setCaretLine = useSetCaretLine(view);
   const setCaretLine = useSetCaretLine(view);
 
 
-  // workaround to fix the doc initialization not working issue -- 2023.08.31 Yuki Takei
-  useEffect(() => {
-    initDoc(' ');
-  }, [initDoc]);
-
   return {
   return {
     state,
     state,
     view,
     view,