@@ -139,12 +139,12 @@ class PathVisualizer extends Component {
139139 } ) ;
140140 animatePath ( this , visitedNodesInOrder , nodesInShortestPathOrder , startNode , finishNode ) ;
141141 } catch ( error ) {
142- this . setState ( { isPathNotFound : true } ) ;
142+ this . setState ( { isPathNotFound : true , isVisualizing : true } ) ;
143143 setTimeout ( ( ) => {
144- this . setState ( { isPathNotFound : false } ) ;
144+ this . setState ( { isPathNotFound : false , isVisualizing : false } ) ;
145145 } , 3000 ) ;
146146 }
147- this . setState ( { isVisualizing : ! this . state . isVisualizing } ) ;
147+ // this.setState({ isVisualizing: false });
148148 }
149149
150150 // dfs
@@ -166,15 +166,15 @@ class PathVisualizer extends Component {
166166 animatePath ( this , visitedNodesInOrder , nodesInShortestPathOrder , startNode , finishNode ) ;
167167 } catch ( error ) {
168168 console . log ( error )
169- this . setState ( { isPathNotFound : true } ) ;
169+ this . setState ( { isPathNotFound : true , isVisualizing : true } ) ;
170170 setTimeout ( ( ) => {
171- this . setState ( { isPathNotFound : false } ) ;
171+ this . setState ( { isPathNotFound : false , isVisualizing : false } ) ;
172172 } , 3000 ) ;
173173 }
174174 }
175175
176176 // bfs
177- visualizeBFS = async ( ) => {
177+ visualizeBFS = ( ) => {
178178 if ( this . state . isVisualizing )
179179 return ;
180180 const { grid, startNode_Pos, finishNode_Pos } = this . state ;
@@ -191,9 +191,9 @@ class PathVisualizer extends Component {
191191 } ) ;
192192 animatePath ( this , visitedNodesInOrder , nodesInShortestPathOrder , startNode , finishNode ) ;
193193 } catch ( error ) {
194- this . setState ( { isPathNotFound : true } ) ;
194+ this . setState ( { isPathNotFound : true , isVisualizing : true } ) ;
195195 setTimeout ( ( ) => {
196- this . setState ( { isPathNotFound : false } ) ;
196+ this . setState ( { isPathNotFound : false , isVisualizing : false } ) ;
197197 } , 3000 ) ;
198198 }
199199 }
@@ -219,9 +219,9 @@ class PathVisualizer extends Component {
219219 } ) ;
220220 animatePath ( this , visitedNodesInOrder , nodesInShortestPathOrder , startNode , finishNode ) ;
221221 } catch ( error ) {
222- this . setState ( { isPathNotFound : true } ) ;
222+ this . setState ( { isPathNotFound : true , isVisualizing : true } ) ;
223223 setTimeout ( ( ) => {
224- this . setState ( { isPathNotFound : false } ) ;
224+ this . setState ( { isPathNotFound : false , isVisualizing : false } ) ;
225225 } , 3000 ) ;
226226 }
227227 }
0 commit comments