component-size icon indicating copy to clipboard operation
component-size copied to clipboard

Only update state when values change

Open OliverJAsh opened this issue 4 years ago • 0 comments

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:

image

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.

OliverJAsh avatar Jun 23 '20 18:06 OliverJAsh