Skip to content

FahimaGold/react-batching-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Checking React Batching

An app that checks how batching works in React 18.2. The app Uses two states variables: a counter that is incremented, and a flag that is toggled between 0 and 1. A button when it is clicked, the states are updated, and the GIF below shows how many times a re-render takes place.

batchOnClick

Then, the states are updated inside a timeout, and the GIF below shows how many re-renders take place.

batchInTimeout

We notice that in the very first state updates, the re-render takes place twice, this is due to the fact that we are using Strict Mode, and in the next state updates, it will be batched and takes place only once.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published