Go ProSign in

This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Advanced React Component Patterns

Advanced React Component Patterns

Autoplay

    Prevent Unnecessary Rerenders of Compound Components using React Context

    Kent C. DoddsKent C. Dodds
    1:37

    Due to the way that React Context Providers work, our current implementation re-renders all our compound component consumers with every render of the <Toggle /> which could lead to unnecessary re-renders. Let's fix that by ensuring that the value prop we pass to the <ToggleContext.Provider /> is only changed when the state changes.

    You must be a Member to view code