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
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#L502
https://github.com/red-hat-storage/odf-console/blob/master/packages/mco/components/mco-dashboard/data-policy/dr-dashboard.tsx#L163

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

@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
red-hat-storage#672
Signed-off-by: Timothy Asir Jeyasingh <tjeyasin@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants