3 ms·
setLoading just pushes an element into a queue. Calling useState will create the queue and fill it with true as initial state during the first call and then run
by imtringued 5y ago
setLoading just pushes an element into a queue. Calling useState will create the queue and fill it with true as initial state during the first call and then run a reducer on the entire queue to calculate the latest state. Simply calling setLoading does not modify loading. When you push an update to a queue react will rerender the component and thereby call useState again which runs the reducer which returns the latest state.
https://news.ycombinator.com/item?id=28972892 https://news.ycombinator.com/item?id=28972892