Summary
The tutorial's Why immutability is important section doesn't clearly state that mutating state causes unreliable re-rendering behavior.
Page
https://react.dev/learn/tutorial-tic-tac-toe#why-immutability-is-important
Details
While following the tic-tac-toe tutorial, I was confused about why .slice()
is necessary. The "Why immutability is important" section talks about time travel features and performance optimizations, but it never explains that mutating the array directly will cause React to not reliably detect the change, meaning the component may not re-render.
It seems as though that is the primary reason the tutorial uses .slice(), but it's not mentioned. I only found this explanation later in the "Updating Objects in State" article. It would be helpful to include this explanation in the tutorial where beginners first encounter the pattern.