DEV Community

Discussion on: React context, performance?

Collapse
 
romaintrotard profile image
Romain Trotard

Thank you :)

I think I'm missing something about "the missing updates" you're talking about, because, for me, the component get the right data and subscribe to its changes thanks to the right selector and useContextSelector, and will be notify to changes corresponding to this data. So if it misses updates, it would probably mean there are problems in the code otherwhere that do not update the data. Am I missing something ?

Ah nice, I didn't know that some library were providing their own "custom hooks". Thanks for the info.

Yep I would also use a library for data fetching like react-query / swr, ... And would definitely give "atom state management" a try when I want to share data between sibling components. In next articles, I will show how to use some of them and talk about their implementations :)

Collapse
 
mbeaudru profile image
Manuel Beaudru

I took more time to read the use-context-selector API, no you are not missing anything - I was 🤭. I thought the second parameter was to define a "key" that would be used to decide when to re-render, but it is instead really a value selector.

Looking forward your next articles then ! :)