My "Game Of Llfe" react project runs very slowly, please help!

My "Game Of Llfe" react project runs very slowly, please help!
0

#1

So I just finished my react project “The Game Of Life”. I’m actually quite proud of what I’ve done and was a very fun challenge to overcome. From the looks of it, it’s working perfectly and the game plays out exactly like it should. Only problem is, when the active cell count it too large it starts to slow down. I have a feeling it has something to do with my logic (inside the update function) where there is a lot going on. Possible my setTimeout() inside the start function. Too much recursion maybe? Anyway, whoever is brave enough to look at my code and help with performance would be greatly appreciated.
Any other advice or reviews are welcome. Thanks!


#2

I’m not going to read through your code since this project tends to be complicated to read, but generally the slowdowns in the Game of Life are caused by re-rendering all of the cells. Instead of setting state to render cells, consider just toggling the class of cells so their color changes. This is a lot faster.


#3

Originally I thought of doing this. Right now I have cells with an “active” state and set the CSS based on that. I’m not sure how to do this with only CSS without actually touching the DOM (which I was told is a big no-no in react). I think I might look at a few examples and see what they do.