Mao 4 yıl önce
ebeveyn
işleme
8dc26e5adf

+ 4 - 3
packages/app/src/components/Navbar/GrowiSubNavigation.jsx

@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useCallback } from 'react';
 import PropTypes from 'prop-types';
 
 import { withUnstatedContainers } from '../UnstatedUtils';
@@ -37,7 +37,7 @@ const GrowiSubNavigation = (props) => {
     navigationContainer.setEditorMode(viewType);
   }
 
-  const tagsUpdatedHandler = async(newTags) => {
+  const tagsUpdatedHandler = useCallback(async(newTags) => {
     // It will not be reflected in the DB until the page is refreshed
     if (editorMode === 'edit') {
       return editorContainer.setState({ tags: newTags });
@@ -56,7 +56,8 @@ const GrowiSubNavigation = (props) => {
     catch (err) {
       toastError(err, 'fail to update tags');
     }
-  };
+  // eslint-disable-next-line react-hooks/exhaustive-deps
+  }, [pageId]);
 
   return (
     <div className={`grw-subnav container-fluid d-flex align-items-center justify-content-between ${isCompactMode ? 'grw-subnav-compact d-print-none' : ''}`}>

+ 0 - 1
packages/app/src/stores/page.tsx

@@ -48,7 +48,6 @@ export const useSWRPageInfo = (pageId: string): SWRResponse<IPageInfo, Error> =>
 };
 
 export const useSWRTagsInfo = (pageId: string): SWRResponse<IPageTagsInfo, Error> => {
-  // apiGet():Promise<unknown>
   return useSWR(`/pages.getPageTag?pageId=${pageId}`, endpoint => apiGet(endpoint).then((response: IPageTagsInfo) => {
     return {
       tags: response.tags,