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:
Alexandre Poirot 2020-08-25 05:31:37 +00:00
Родитель 2d1453c463
Коммит 26f8349cef
1 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -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();