I want to change only one element of a multidimensional array
// nodes is a 2-dimensional array
// of 30 rows and 30 columns
this.state = {nodes};
// updatedNodes is a deep copy of nodes
updatedNodes[row][col].isVisited = true;
setState({nodes : updatedNodes });
When I run the above code multiple times by changing the values of row and col, it starts lagging. I guess, its because all the elements are updated every time. I just want to update the element which I am changing, instead of all the elements. How can I do it?
Also, when I run the above code in a looping statement, it lags and changes in multiple elements are reflected together.