Skip to content

Commit 6a828d6

Browse files
committed
dev: Fix "setState on Unmounted Component" error for AutoComplete field.
1 parent 67e42d5 commit 6a828d6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

build/app/view/netcreate/components/AutoComplete.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class AutoComplete extends UNISYS.Component {
221221
/*/ onStateChange_SELECTION ( data ) {
222222
if (DBG) console.log('...AutoComplete',this.props.identifier,': Got SELECTION',data);
223223
if (this.props.shouldIgnoreSelection) {
224-
if (DBG) console.error('...AutComplete',this.props.identifier,': Ignoring SELECTION (probably because NodeSelector is in edit mode).');
224+
if (DBG) console.log('...AutComplete',this.props.identifier,': Ignoring SELECTION (probably because NodeSelector is in edit mode).');
225225
return;
226226
}
227227
let activeAutoCompleteId = this.AppState('ACTIVEAUTOCOMPLETE').activeAutoCompleteId;
@@ -343,9 +343,13 @@ class AutoComplete extends UNISYS.Component {
343343
this.setState({ mode: this.props.inactiveMode });
344344
}
345345
/*/
346-
/*/ componentWillUnmount () {
347-
_IsMounted = false;
348-
}
346+
/*/
347+
componentWillUnmount() {
348+
_IsMounted = false;
349+
// deregister ACTIVEAUTOMPLETE when component unmounts
350+
// otherwise state updates trigger a setState on unmounted component error
351+
this.AppStateChangeOff('ACTIVEAUTOCOMPLETE', this.onStateChange_AUTOCOMPLETE);
352+
}
349353

350354
/*/ Conditionally render components based on current 'mode'. The mode
351355
is passed

0 commit comments

Comments
 (0)