Taichi Masuyama 4 лет назад
Родитель
Сommit
91f4e9f7a1

+ 9 - 9
packages/app/src/components/Admin/SlackIntegration/ManageCommandsProcess.jsx

@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useCallback, useState } from 'react';
 import PropTypes from 'prop-types';
 import PropTypes from 'prop-types';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
 import { defaultSupportedCommandsNameForBroadcastUse, defaultSupportedCommandsNameForSingleUse } from '@growi/slack';
 import { defaultSupportedCommandsNameForBroadcastUse, defaultSupportedCommandsNameForSingleUse } from '@growi/slack';
@@ -90,7 +90,7 @@ const ManageCommandsProcess = ({
     return initialState;
     return initialState;
   });
   });
 
 
-  const updatePermissionsForBroadcastUseCommandsState = (e) => {
+  const updatePermissionsForBroadcastUseCommandsState = useCallback((e) => {
     const { target } = e;
     const { target } = e;
     const { name: commandName, value } = target;
     const { name: commandName, value } = target;
 
 
@@ -103,9 +103,9 @@ const ManageCommandsProcess = ({
       newState[commandName] = value;
       newState[commandName] = value;
       return newState;
       return newState;
     });
     });
-  };
+  }, []);
 
 
-  const updatePermissionsForSingleUseCommandsState = (e) => {
+  const updatePermissionsForSingleUseCommandsState = useCallback((e) => {
     const { target } = e;
     const { target } = e;
     const { name: commandName, value } = target;
     const { name: commandName, value } = target;
 
 
@@ -118,25 +118,25 @@ const ManageCommandsProcess = ({
       newState[commandName] = value;
       newState[commandName] = value;
       return newState;
       return newState;
     });
     });
-  };
+  }, []);
 
 
-  const updateChannelsListForBroadcastUseCommandsState = (e) => {
+  const updateChannelsListForBroadcastUseCommandsState = useCallback((e) => {
     const { target } = e;
     const { target } = e;
     const { name: commandName, value } = target;
     const { name: commandName, value } = target;
     // update state
     // update state
     setPermissionsForBroadcastUseCommandsState((prevState) => {
     setPermissionsForBroadcastUseCommandsState((prevState) => {
       return getUpdatedChannelsList(prevState, commandName, value);
       return getUpdatedChannelsList(prevState, commandName, value);
     });
     });
-  };
+  }, []);
 
 
-  const updateChannelsListForSingleUseCommandsState = (e) => {
+  const updateChannelsListForSingleUseCommandsState = useCallback((e) => {
     const { target } = e;
     const { target } = e;
     const { name: commandName, value } = target;
     const { name: commandName, value } = target;
     // update state
     // update state
     setPermissionsForSingleUseCommandsState((prevState) => {
     setPermissionsForSingleUseCommandsState((prevState) => {
       return getUpdatedChannelsList(prevState, commandName, value);
       return getUpdatedChannelsList(prevState, commandName, value);
     });
     });
-  };
+  }, []);
 
 
   // TODO: UPDATE API AND REWRITE HERE GW-7006
   // TODO: UPDATE API AND REWRITE HERE GW-7006
   const updateCommandsHandler = async() => {
   const updateCommandsHandler = async() => {