Current section: Optimize Context 33 exercises
Problem

Provider Component

Loading exercise

Transcript

00:00 So we've got another interesting issue. If we record this, and I change something about the footer and Kodi, then stop that. We're going to have a bunch of renders for the typing Kodi. But you'll notice that we're re-rendering main and we're re-rendering app, even though those don't care

00:16 about the name and the footer. That's external to those things. They shouldn't have to re-render in that case. And so we're going to be creating a provider component, so a component that's responsible for rendering the context. This is actually one of those optimizations that people just do naturally. It's pretty normal to create a provider component,

00:36 but I thought it was useful to have a step here to explain that that actually is a performance improvement when you can do that, because it means that changes to the context value do not necessarily re-render the children of the context. So let's take a look at what that does.