diff --git a/src/renderers/dom/client/wrappers/ReactDOMSelect.js b/src/renderers/dom/client/wrappers/ReactDOMSelect.js index 23462d61d4ab4..f0ac23fca1a3d 100644 --- a/src/renderers/dom/client/wrappers/ReactDOMSelect.js +++ b/src/renderers/dom/client/wrappers/ReactDOMSelect.js @@ -236,7 +236,9 @@ function _handleChange(event) { var props = this._currentElement.props; var returnValue = LinkedValueUtils.executeOnChange(props, event); - this._wrapperState.pendingUpdate = true; + if (this._rootNodeID) { + this._wrapperState.pendingUpdate = true; + } ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this); return returnValue; } diff --git a/src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js b/src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js index 4d9472472e3b8..97736bc99a552 100644 --- a/src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js +++ b/src/renderers/dom/client/wrappers/__tests__/ReactDOMSelect-test.js @@ -517,4 +517,24 @@ describe('ReactDOMSelect', function() { ); expect(console.error.argsForCall.length).toBe(1); }); + + it('should be able to safely remove select onChange', function() { + function changeView() { + ReactDOM.unmountComponentAtNode(container); + } + + var container = document.createElement('div'); + var stub = + ; + stub = ReactDOM.render(stub, container); + var node = ReactDOM.findDOMNode(stub); + + expect(() => ReactTestUtils.Simulate.change(node)).not.toThrow( + "Cannot set property 'pendingUpdate' of null" + ); + }); });