Why React setState runs only once even when we call it multiple times 🤯, React interview Questions
Автор: DIYCode
Загружено: 2026-02-15
Просмотров: 9
Описание:
Why React setState runs only once even when we call it multiple times 🤯
Many developers expect this code to increase the counter by 4:
setCounter(counter + 1)
setCounter(counter + 1)
setCounter(counter + 1)
setCounter(counter + 1)
But React increases it by only 1.
Why?
Because React batches state updates and uses the same state snapshot inside the function.
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: