Skip to content

Commit

Permalink
fix: avoid unnecessary rerenders (#7004)
Browse files Browse the repository at this point in the history
* fix: avoid unnecessary rerenders while assets are loading

* fix: formatting

---------

Co-authored-by: spereirag <sapereirag@gmai.com>
Co-authored-by: Anze Demsar <anze.demsar@p-m.si>
  • Loading branch information
3 people authored Dec 19, 2023
1 parent 2ec8406 commit fdfb497
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class EditorControl extends React.Component {
parentIds,
t,
validateMetaField,
isLoadingAsset,
isDisabled,
isHidden,
isFieldDuplicate,
Expand Down Expand Up @@ -329,6 +330,7 @@ class EditorControl extends React.Component {
isDisabled={isDisabled}
isFieldDuplicate={isFieldDuplicate}
isFieldHidden={isFieldHidden}
isLoadingAsset={isLoadingAsset}
locale={locale}
/>
{fieldHint && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export default class Widget extends Component {
};

shouldComponentUpdate(nextProps) {
/**
* Avoid unnecessary rerenders while loading assets.
*/
if (this.props.isLoadingAsset) return false;
/**
* Allow widgets to provide their own `shouldComponentUpdate` method.
*/
Expand Down

0 comments on commit fdfb497

Please sign in to comment.