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

Added Filter to allow skip re-render in context consumers #26892

Closed

Conversation

eduardocque
Copy link

@eduardocque eduardocque commented Jun 2, 2023

Summary

The reason of this change is to have a way to skip re-renders in some consumers based on the previous state and new state or in case that i just want to re-render if a specific sub value inside the context changes

This allow to improve the performance in large applications without be making many context just to parse the value trying to avoid re-renders

image

i tested the implementation with an existing react application (small) where using devTools i was able to confirm that the elements that i was specting to be skipped were skipped

How did you test this change?

#26890 in this ticket i left a codesandbox example about the proposal implementation

just will require to run it locally and replace react and react-dom to be able to test the changes and verified using devTools

in my case i was using this command yarn build react/index,react-dom/index,react/jsx-runtime,react-dom/src/server --type=NODE_DEV

image

@facebook-github-bot
Copy link

Hi @eduardocque!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@react-sizebot
Copy link

react-sizebot commented Jun 2, 2023

Comparing: e1ad4aa...5d57667

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js +0.10% 164.23 kB 164.40 kB +0.08% 51.73 kB 51.77 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.10% 171.67 kB 171.83 kB +0.08% 53.97 kB 54.01 kB
facebook-www/ReactDOM-prod.classic.js +0.14% 570.12 kB 570.94 kB +0.10% 100.57 kB 100.67 kB
facebook-www/ReactDOM-prod.modern.js +0.15% 553.90 kB 554.72 kB +0.11% 97.75 kB 97.86 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ReactART-prod.modern.js +0.24% 338.61 kB 339.44 kB +0.22% 57.55 kB 57.68 kB
facebook-www/ReactART-prod.classic.js +0.24% 349.61 kB 350.44 kB +0.21% 59.47 kB 59.60 kB

Generated by 🚫 dangerJS against 5d57667

@eduardocque eduardocque changed the title [WIP] Added Filter to allow skip re-render in context consumers Added Filter to allow skip re-render in context consumers Jun 2, 2023
@eduardocque
Copy link
Author

eduardocque commented Jun 2, 2023

im trying to fix the unit tests but not sure how to fix those in www-classic and www-modern

when is lazy works in a different way using the method propagateContextChanges in packages/react-reconciler/src/ReactFiberNewContext.js

i am able to filter it properly https://github.com/facebook/react/pull/26892/files#diff-679d7152ac09925cae543a85080b8735252ef49da7f6fcde698f48ca36921688R433 but still re-rendering so i think i am missing something when is lazy but at this point i would need help from someone that knows more the project to be able to handle that scenario and probably discuss how to handle scenarios like SSR and when is suspended, classMode, etc

any suggestions ?

Copy link

github-actions bot commented Apr 9, 2024

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

@github-actions github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Apr 9, 2024
Copy link

Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

@github-actions github-actions bot closed this Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Resolution: Stale Automatically closed due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants