React Automatic Batching: How Many Re-renders?

Published: (December 14, 2025 at 10:51 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Example

import { useState } from 'react';

const App = () => {
  const [name, setName] = useState('');
  const [age, setAge] = useState(null);
  const [hobby, setHobby] = useState('');

  const displayPerson = () => {
    setName('Luiji');
    setAge(29);
    setHobby('swimming');
  };

  console.log('Component rendered');

  return (
    <>
      
### {name}

      
### {age}

      
#### Enjoys: {hobby}

      
        {name === 'Yoshi' ? 'Display Person' : 'Person Displayed'}
      
    
  );
};

export default App;

When you click the button, the component re‑renders once, not three times. This is because React automatically batches the state updates that occur within the same event loop.

Note: The first console.log runs on the initial render; the second runs after the button click triggers the re‑render.

What is Batching?

Batching groups multiple state updates into a single render pass, reducing unnecessary work and improving performance. In React 18, automatic batching is enabled by default and works for:

  • Native event handlers (e.g., clicks)
  • Asynchronous operations (e.g., promises)
  • Timeouts and intervals

Because all three setState calls (setName, setAge, setHobby) happen during the same click event, React batches them and performs only one render.

0 views
Back to Blog

Related posts

Read more »

Preferred Web Tech Stacks in Australia

Why Tech Stack Selection Matters in Australia Australian businesses prioritize quality, security, and performance. Websites are expected to work seamlessly acr...

Under the hood: React

Introduction I've wanted to do this since the moment I started using React: understand what makes it tick. This is not a granular review of the source code. In...