Current section: Optimize Context 33 exercises
solution

Memoize Context

Loading solution

Transcript

00:00 Alright, we've got our memoized footer, we have our use footer, we have our footer context, all of this. And the problem is that our footer context value is changing every render because we're creating a brand new object every time. So triple equals false.

00:14 We need to make it so that these, this object will only be a different object if the properties of it are different. So we're going to add use memo from react here. And that will wrap this guy.

00:29 And we'll let the ESLint plugin throw those values in there, save that. And then if we clear this out and record and increment the app count, then we should not see the footer re-render in here because the context value itself didn't change. So this value remained the same.

00:48 Of course, you do want to make sure that it is still able to perform the stuff that it's supposed to do. But yeah, that seems to be working just fine.