-
Notifications
You must be signed in to change notification settings - Fork 549
chore: refactor ExplorerProvider to use context selector #3108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: refactor ExplorerProvider to use context selector #3108
Conversation
✅ Deploy Preview for peaceful-bassi-cbf284 canceled.
|
How long do you think it will take for reactjs to implement the solution ? because the issue was created on 2019 and last comment was on 2021... |
@rephus No idea 🤷 hopefully in react 19 since this is a really obvious problem. |
@ZeRego I'm fine with the choice. Library code uses react internals and nothing else so that's good. hopefully that will get merged. random thought:
|
801bbe6
to
555a2e2
Compare
555a2e2
to
6bece78
Compare
🎉 This PR is included in version 0.239.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Related to: #2997
Description:
Main problem:
useContext doesn't let you subscribe to a part of the context value (or some memoized selector) without fully re-rendering.
Issue being tracked here: facebook/react#14110
There is a proposal under development/review reactjs/rfcs#119
So in this PR I'm using a library that polyfills the proposal so once it's introduced in react we can easily migrate.
Library: https://github.com/dai-shi/use-context-selector
Before:
After:
Top 3 providers that need to be changed:
I can make a PR for each one since it implies changes in lots of files and avoid merge conflicts. I can also make it backwards compatible so any existing PR merged would still be compatible ( it would still have bad performance )
This PR only refactors
ExplorerProvider
.