State consists of all of the dynamic data in your component. Whenever the value of state changes the entire react component and all of its children need to rerender.
As for this example, when your state update relies on a previous value of state, for example if you have a counter and you want to add one to it each time a button is clicked, instead of using the state directly, you need to pass a callback function to the setState function. The function that you pass to the setState function will get the previous snapshot of state and props automatically and you can use them to make further updates. this is just an example that demonstrates it.
Passing a callback function to the setState function is really important when you wanna make sure that you have the most updated value of the previous state. if you want to read more about it, here’s an article that can help you understand it clearly.