You should use the callback in setState
if you want to do that because it is async. Please refer to the following link to get more info:
https://reactjs.org/docs/react-component.html#setstate
Another alternative is to set the state only once instead of doing it multiple times. You don’t need to put all that info in the state only to update one value. And even if you do need all that info, you can use one setState
call instead of 3 like you are doing. Just set variables with the values that you want to set and do one update.
solved I need of help in found one solution on problem, React,Firebase,For Loop [closed]