From 1f1cd701754d5aa0330e46d7b9265b10a8831488 Mon Sep 17 00:00:00 2001 From: SAI SUMANTH KUMAR Date: Sun, 24 Oct 2021 19:45:37 +0530 Subject: [PATCH] To perform an action immediately after setting state on a state variable and then returning a result, a callback will be useful. (#1229) * Update Editor.jsx * fixed typo --- frontend/src/Editor/Editor.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/Editor/Editor.jsx b/frontend/src/Editor/Editor.jsx index b9de7f30c9..1d5c0d5637 100644 --- a/frontend/src/Editor/Editor.jsx +++ b/frontend/src/Editor/Editor.jsx @@ -462,7 +462,7 @@ class Editor extends React.Component { }; toggleQueryEditor = () => { - this.setState({ showQueryEditor: !this.state.showQueryEditor }); + this.setState((prev) => ({ showQueryEditor: !prev.showQueryEditor })); this.toolTipRefHide.current.style.display = this.state.showQueryEditor ? 'none' : 'flex'; this.toolTipRefShow.current.style.display = this.state.showQueryEditor ? 'flex' : 'none'; }; @@ -490,7 +490,7 @@ class Editor extends React.Component { }; toggleQuerySearch = () => { - this.setState({ showQuerySearchField: !this.state.showQuerySearchField }); + this.setState((prev) => ({ showQuerySearchField: !prev.showQuerySearchField })); }; onVersionDeploy = (versionId) => {