AutosuggestTextarea: shouldComponentUpdate fixes

config-ui-updates
Alex Gleason 2020-09-28 23:54:47 -05:00
rodzic 4ae029c8d9
commit a7d2692a71
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -160,9 +160,12 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
}
shouldComponentUpdate(nextProps, nextState) {
// Skip updating when lastToken changes so the cursor doesn't jump around
// due to re-rendering unnecessarily
if (this.state.lastToken !== nextState.lastToken) {
// Skip updating when only the lastToken changes so the
// cursor doesn't jump around due to re-rendering unnecessarily
const lastTokenUpdated = this.state.lastToken !== nextState.lastToken;
const valueUpdated = this.props.value !== nextProps.value;
if (lastTokenUpdated && !valueUpdated) {
return false;
} else {
return super.shouldComponentUpdate(nextProps, nextState);