Skip to content
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

Open
SanjalKatiyar opened this issue Mar 6, 2023 · 3 comments · May be fixed by #1410
Assignees

Comments

@SanjalKatiyar
Copy link
Collaborator

SanjalKatiyar commented Mar 6, 2023

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

@SanjalKatiyar
Copy link
Collaborator Author

cc @bipuladh @GowthamShanmugam (just FYI)

@black-dragon74
Copy link
Contributor

@SanjalKatiyar can I take this one?

@SanjalKatiyar
Copy link
Collaborator Author

SanjalKatiyar commented Mar 28, 2023

@SanjalKatiyar can I take this one?

/assign @debjyoti-pandit
Hi,
this is already assigned (forgot to update the issue) and WIP.

@SanjalKatiyar 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
TimothyAsirJeyasing added a commit to TimothyAsirJeyasing/odf-console that referenced this issue Jun 20, 2024
TimothyAsirJeyasing added a commit to TimothyAsirJeyasing/odf-console that referenced this issue Jun 25, 2024
TimothyAsirJeyasing added a commit to TimothyAsirJeyasing/odf-console that referenced this issue Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants