component-size
component-size copied to clipboard
Only update state when values change
Reduced test case: https://stackblitz.com/edit/react-9vjncm
Here we are logging the size every time its reference changes. The actual size never actually changes.
As you can see, this results in 4 logs:
I would only expect the first two to be logged, since the last two are duplicates—the size has not changed.
This could result in wasted re-renders.