Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 反应JS。按下按钮后,移除按钮的功能_Javascript_Reactjs - Fatal编程技术网

Javascript 反应JS。按下按钮后,移除按钮的功能

Javascript 反应JS。按下按钮后,移除按钮的功能,javascript,reactjs,Javascript,Reactjs,如何卸载。返回不起作用。我需要能够按下按钮,功能完成后,该功能将从按钮删除 const handleSubmit = () => { ipcRenderer.send( "EDITOR", [ type, typeValue], "editor_response" ); onClose(selectedValue); }; return <div> <

如何卸载。返回不起作用。我需要能够按下按钮,功能完成后,该功能将从按钮删除


  const handleSubmit = () => {
    ipcRenderer.send(
      "EDITOR",
      [ type, typeValue],
      "editor_response"
    );
    onClose(selectedValue);
  };

  return <div>
    <Button onClick={handleSubmit} color="primary">
      Ok
    </Button>
  </div>

常量handleSubmit=()=>{
ipc.send(
“编辑”,
[类型,类型值],
“编辑回应”
);
onClose(selectedValue);
};
返回
好啊

最干净的解决方案可能是一个状态变量,用于确定处理程序是否应处于活动状态

constmycop=()=>{
const[pressed,setPressed]=使用状态(false;
常量handleSubmit=()=>{
setPressed(true);
ipc.send(
“编辑”,
[类型,类型值],
“编辑回应”
);
onClose(selectedValue);
};
常量noop=()=>{};
返回
好啊
;
};

Add
hasBeenClicked:false
到状态,在第一次单击后将其更新为
true
,并在下一次单击时检查其值以退出该函数。