The Call Kent Podcast

Bailing out of re-rendering in useState


Listen Later

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?

  • useState lazy initialization and function updates
  • ...more
    View all episodesView all episodes
    Download on the App Store

    The Call Kent PodcastBy Kent C. Dodds

    • 5
    • 5
    • 5
    • 5
    • 5

    5

    2 ratings


    More shows like The Call Kent Podcast

    View all
    The Changelog: Software Development, Open Source by Changelog Media

    The Changelog: Software Development, Open Source

    288 Listeners

    Syntax - Tasty Web Development Treats by Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers

    Syntax - Tasty Web Development Treats

    990 Listeners

    PodRocket by LogRocket

    PodRocket

    61 Listeners