#react

React: Avoid Unnecessary Renders with Batch State Updates

React: Avoid Unnecessary Renders with Batch State Updates

February 10, 2022 • 6 min read

Have you ever wondered why your component is re-rendering multiple time consecutively when you only expect it to re-render once? Perhaps you update some local state and somehow multiple renders occur as a result? Lets take this hooks based example: