Skip to content

Only update state when values change #34

Open
@OliverJAsh

Description

@OliverJAsh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions