-
Notifications
You must be signed in to change notification settings - Fork 32
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
[perf-improv] Create separate provider for the context and pass its descendants as a "children" #672
Comments
cc @bipuladh @GowthamShanmugam (just FYI) |
@SanjalKatiyar can I take this one? |
/assign @debjyoti-pandit |
SanjalKatiyar
changed the title
[perf-improv] create separate provider for the context and pass its descendants as a "children"
[perf-improv] Create separate provider for the context and pass its descendants as a "children"
Feb 26, 2024
TimothyAsirJeyasing
added a commit
to TimothyAsirJeyasing/odf-console
that referenced
this issue
May 30, 2024
red-hat-storage#672 Signed-off-by: Timothy Asir Jeyasingh <[email protected]>
TimothyAsirJeyasing
added a commit
to TimothyAsirJeyasing/odf-console
that referenced
this issue
Jun 20, 2024
red-hat-storage#672 Signed-off-by: Timothy Asir Jeyasingh <[email protected]>
TimothyAsirJeyasing
added a commit
to TimothyAsirJeyasing/odf-console
that referenced
this issue
Jun 25, 2024
red-hat-storage#672 Signed-off-by: Timothy Asir Jeyasingh <[email protected]>
TimothyAsirJeyasing
added a commit
to TimothyAsirJeyasing/odf-console
that referenced
this issue
Aug 5, 2024
red-hat-storage#672 Signed-off-by: Timothy Asir Jeyasingh <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently used:
https://github.com/red-hat-storage/odf-console/blob/master/packages/odf/components/topology/Topology.tsx#L575
https://github.com/red-hat-storage/odf-console/blob/master/packages/mco/components/mco-dashboard/disaster-recovery/dr-dashboard.tsx#L128
Refer: https://reactjs.org/docs/context.html#contextprovider
All consumers that are descendants of a Provider will re-render whenever the Provider’s value prop changes.
Whenever Provider’s value prop changes all the child FCs will get re-rendered (irrespective of whether a child is a consumer of the context or not). This will cause unnecessary re-renders for those FCs which are not consuming any state from the context.
To avoid that use composition: create a separate FC which will provide the context and pass the consumer FCs as its "children".
example: https://github.com/openshift/console/blob/master/frontend/public/components/app.jsx#L241
The text was updated successfully, but these errors were encountered: