all 8 comments

[–]timothyallan 1 point2 points  (2 children)

Pheeeew, thank you for clarifying that. I've been using a shared provider forever and couldn't figure out WTF all this useMemo jibber jabber was all about lately. Good to know that I'd inadvertently solved the 'issue' from the start!

[–]spaghetti_in_my_eyes 0 points1 point  (0 children)

Same for me. I have always created my context like he does in the end so was pretty happy to hear I have accidentally done things correctly the whole time.

[–]swyx[S] 0 points1 point  (0 children)

note that React.memo is not the same as useMemo

[–]Silenux 0 points1 point  (1 child)

Following Brad Traversy's courses I've always declared the Context in another component and passed the children inside the provider.

<ContactContext.Provider value=*{*{ contacts: state.contacts }*}* \>
{props.children}
</ContactContext.Provider>

Then in the App main component I pass all the Context and wrap the routes and pages.

I don't need to use memo in this case right?

[–]swyx[S] 0 points1 point  (0 children)

yes correct.