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

improve reseting unsaved warning

Yuki Takei 3 лет назад
Родитель
Сommit
28709dbdbc
1 измененных файлов с 8 добавлено и 0 удалено
  1. 8 0
      packages/app/src/components/PageEditor.tsx

+ 8 - 0
packages/app/src/components/PageEditor.tsx

@@ -324,6 +324,14 @@ const PageEditor = React.memo((props: Props): JSX.Element => {
   const scrollEditorByPreviewScrollWithThrottle = useMemo(() => throttle(20, scrollEditorByPreviewScroll), [scrollEditorByPreviewScroll]);
   const scrollEditorByPreviewScrollWithThrottle = useMemo(() => throttle(20, scrollEditorByPreviewScroll), [scrollEditorByPreviewScroll]);
 
 
 
 
+  // initialize
+  useEffect(() => {
+    if (initialValue != null) {
+      setMarkdown(initialValue);
+      mutateIsEnabledUnsavedWarning(false);
+    }
+  }, [initialValue, mutateIsEnabledUnsavedWarning]);
+
   // initial caret line
   // initial caret line
   useEffect(() => {
   useEffect(() => {
     if (editorRef.current != null) {
     if (editorRef.current != null) {