-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Feat/optimize editor performance #7719
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
Changes from all commits
cc5f0c7
8533c94
536be27
631a53e
9c36573
46f1917
fba6809
0b612da
51a5bd8
03e9e5a
67c019d
29c4f19
eaff8e4
e999a33
dcc88b0
3f0621c
c665461
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { css, ClassNames } from '@emotion/react'; | |||||||||||||||||||||||||||||||||||||
| import { List, Map, fromJS } from 'immutable'; | ||||||||||||||||||||||||||||||||||||||
| import partial from 'lodash/partial'; | ||||||||||||||||||||||||||||||||||||||
| import isEmpty from 'lodash/isEmpty'; | ||||||||||||||||||||||||||||||||||||||
| import memoize from 'lodash/memoize'; | ||||||||||||||||||||||||||||||||||||||
| import uniqueId from 'lodash/uniqueId'; | ||||||||||||||||||||||||||||||||||||||
| import { v4 as uuid } from 'uuid'; | ||||||||||||||||||||||||||||||||||||||
| import DecapCmsWidgetObject from 'decap-cms-widget-object'; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -256,10 +257,18 @@ export default class ListControl extends React.Component { | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| uniqueFieldId = uniqueId(`${this.props.field.get('name')}-field-`); | ||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||
| * Old comment: | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
| * Always update so that each nested widget has the option to update. This is | ||||||||||||||||||||||||||||||||||||||
| * required because ControlHOC provides a default `shouldComponentUpdate` | ||||||||||||||||||||||||||||||||||||||
| * which only updates if the value changes, but every widget must be allowed | ||||||||||||||||||||||||||||||||||||||
| * to override this. | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
| * New comment: | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
| * Each Widget is wrapped with EditorControl which already tries to update every time. | ||||||||||||||||||||||||||||||||||||||
| * Is there a specific reason we need to always rerender the list? | ||||||||||||||||||||||||||||||||||||||
| * This seems overkill. | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+260
to
+271
|
||||||||||||||||||||||||||||||||||||||
| * Old comment: | |
| * | |
| * Always update so that each nested widget has the option to update. This is | |
| * required because ControlHOC provides a default `shouldComponentUpdate` | |
| * which only updates if the value changes, but every widget must be allowed | |
| * to override this. | |
| * | |
| * New comment: | |
| * | |
| * Each Widget is wrapped with EditorControl which already tries to update every time. | |
| * Is there a specific reason we need to always rerender the list? | |
| * This seems overkill. | |
| * Always re-render the list control. | |
| * | |
| * The parent ControlHOC implements a `shouldComponentUpdate` optimization | |
| * based primarily on the list value. Nested widgets inside the list may | |
| * depend on other props or local state, so we disable that optimization | |
| * here and let React reconcile all children on every update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like some feedback on this. Is it really needed for the widget to always rerender?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sempostma, sorry for the late reply. I'm not really sure, you could be right. But thorough testing is needed if we disable rerender here. Decap is used in many ways, and this could have some side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that but shouldComponentUpdate -> true is a very brute force method. It will grind the virtual DOM down to a crawl.
shouldComponentUpdate: true is mostly used to mask another issue, namely that some piece of data is being updated mutably instead of immutably.
This is basically a piece of technical debt that should be cut out with precision but we can also just leave the comment there for future reference?
Uh oh!
There was an error while loading. Please reload this page.