Sveriges mest populära poddar
The Call Kent Podcast

Bailing out of re-rendering in useState

4 min5 november 2021

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?

Fler avsnitt av The Call Kent Podcast

Visa alla avsnitt av The Call Kent Podcast

The Call Kent Podcast med Kent C. Dodds finns tillgänglig på flera plattformar. Informationen på denna sida kommer från offentliga podd-flöden.