зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1660897 - Avoid updating the JS context selector too many times. r=nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D88073
This commit is contained in:
Родитель
2d1453c463
Коммит
26f8349cef
|
@ -52,6 +52,23 @@ class EvaluationContextSelector extends Component {
|
|||
};
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
if (this.props.selectedTarget !== nextProps.selectedTarget) {
|
||||
return true;
|
||||
}
|
||||
if (this.props.targets.length !== nextProps.targets.length) {
|
||||
return true;
|
||||
}
|
||||
for (let i = 0; i < nextProps.targets.length; i++) {
|
||||
const target = this.props.targets[i];
|
||||
const nextTarget = nextProps.targets[i];
|
||||
if (target.url != nextTarget.url || target.name != nextTarget.name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.selectedTarget !== prevProps.selectedTarget) {
|
||||
this.props.updateInstantEvaluationResultForCurrentExpression();
|
||||
|
|
Загрузка…
Ссылка в новой задаче