-
Notifications
You must be signed in to change notification settings - Fork 1.3k
perf: avoid unnecessary re-renders with the suspense mode #979
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: avoid unnecessary re-renders with the suspense mode #979
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 0771899:
|
Sorry for the delay and thank you for this PR!
Mainly because that Suspense is still an experimental feature, and we are not implementing it 100% correctly (mostly with Concurrent mode). Also according to facebook/react#17526 (comment), I feel that it's better to not optimize it too early, and get everyone relying on it too much. |
@shuding Thank you! I understand your concern. |
Yeah I think I agree with applying those perf optimizations for now since they are not specifically for Suspense. Also the code is much cleaner 👍 |
Thank you! |
Fixes #454
Currently, SWR doesn't apply the performance optimization mentioned in https://swr.vercel.app/advanced/performance with the
suspense
option, and it leads to unnecessary re-renders.I've applied the same optimization using
stateDependencies
for thesuspense
mode.Is there any reason not to apply the optimization for the
suspense
mode?This is a fork of reproduction in #454, which is based on this PR.