PLAY PODCASTS
Bailing out of re-rendering in useState
Season 1 · Episode 41

Bailing out of re-rendering in useState

Dale asked this on 2021-11-05

The Call Kent Podcast

November 5, 20214m 28s

Audio is streamed directly from the publisher (media.transistor.fm) as published in their RSS feed. Play Podcasts does not host this file. Rights-holders can request removal through the copyright & takedown page.

Show Notes

If useState contains a simple value like string or int, setting a new value that is the same as the existing value will not cause the component to re-render. However, if useState contains an object and I update the state with a new object that contains the exact same values, it will trigger the component to re-render. The React documentation says that is used Object.is to compare values. My 2 objects are identical, so why does the re-render happen?

Topics

useState