-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
DataViews: prevent unnecessary re-renders #57452
Merged
oandregal
merged 1 commit into
trunk
from
update/components-remain-unchanged-by-data-updates
Dec 29, 2023
Merged
DataViews: prevent unnecessary re-renders #57452
oandregal
merged 1 commit into
trunk
from
update/components-remain-unchanged-by-data-updates
Dec 29, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What Memoize Search, ViewActions, and Filters components. Why To prevent unnecessary re-renders. How The data retrieval hook (useEntityRecords) may be updated up to 4 times, according to its lifecycle. The data props (data, isLoading) may change so DataViews will re-render as well. There are some components that do not depend on data prop updates, they only depend on field & view updates. These should not re-render.
oandregal
added
[Type] Experimental
Experimental feature or API.
[Feature] DataViews
Work surrounding upgrading and evolving views in the site editor and beyond
labels
Dec 29, 2023
Size Change: +24 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
oandregal
requested review from
ntsekouras,
youknowriad and
jorgefilipecosta
December 29, 2023 12:28
oandregal
deleted the
update/components-remain-unchanged-by-data-updates
branch
December 29, 2023 12:50
I just realized that there is other component in the same situation: |
@oandregal Great work on these performance improvements. Do you think we should add a metric to track these improvements and prevent future regressions? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Feature] DataViews
Work surrounding upgrading and evolving views in the site editor and beyond
[Type] Experimental
Experimental feature or API.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of #55083
Related #57390 #57393 #57450 #57454 #57458
What
Memoize Search, ViewActions, and Filters components.
Why
By preventing unnecessary re-renders,
DataViews
is ~33% faster in events that trigger data retrieval.DataViews
(one round, not median)DataViews
DataViews
ViewActions
(same forSearch
andFilters
)ViewActions
How
The data retrieval hook (
useEntityRecords
) may trigger up to 4 updates, according to its lifecycle (idle, resolving with old data, resolving with new data, success). Each cause the Pages component to render, and soDataViews
.The data props (
data
,isLoading
) may change in any of those updates, but theview
andfield
props are updated only once (the first). There are someDataViews
components that do not depend on data props, they only depend onfield
&view
. This PR prevents them from re-rendering iffield
andview
props have not changed.How to test
You can load the profiles in the React DevTools Profiler and take a look at the
DataViews
components. Alternatively, you can test it by:DataViews
,Search
,Filters
, andViewActions
components.DataViews
is rendered 4 times whileSearch
,Filters
, andViewActions
is only rendered once. Before this PR, they'd render 4 times as well.Search
,Filters
, andViewActions
are still rendered once: this is correct, as theview
changes (view.perPage
is updated from 20 to 10). Fine-grained rendering forDataViews
needs to be looked at separately.Gravacao.do.ecra.2023-12-29.as.13.44.38.mov