Transcript
00:00 One thing you might have noticed is that our footer setters are re-rendering when we make a change, even to the context value. And if you take a look at this, there's our footer setters right there. There's actually nothing in the footer setter that depends on the color or name values. The values are not read, they're only set.
00:19 And so it's actually an unnecessary re-render for this thing to re-render anytime the context value changes because it doesn't depend on the value, it just depends on the setters. This is a super edge case thing that I've never actually seen a production environment where this was necessary, but I've not seen every production environment there is.
00:39 And I have been told that some people have actually gotten value out of this. That's why I'm including it in our exercise today. But I just want to stress that you probably don't need to do this. But if you ever find yourself in a situation, maybe you're doing some sort of charting thing,
00:54 or it's like a giant table, or some complex drag and drop following mouse moves and stuff, where you're updating state like constantly, or you're on really low end devices or something, some scenario where it actually could make sense for you, then that's what this exercise is for. The idea is simple.
01:12 Instead of having a single value, you actually have two values, one for the setters and one for the state. And then you have two separate contexts, one context for the state, one context for the setters. And then you consume just the context that you're looking for.
01:29 And it is a little bit more work, but it's not a lot. And it makes things pretty quick and easy. So that's what you're going to be doing in this step. It's just some shuffling around of some components and things, not a ton of changes.
01:43 But when you're done, you should be able to make a change to the state that's in the footer context. So either the color or the name. And you should, in fact, you should never see the footer setters re-render when those values change. So good luck.