Closed
Description
Related to #2393
Rendering a component like this:
<div onClick={() => this.setState({something: 1}) />
rendering via shallow render, then calling handler
var result = shallowRenderer.getRenderOutput();
result.props.onClick()
Produces the following:
ReferenceError: document is not defined
at getActiveElement (myapp/node_modules/react/lib/getActiveElement.js:23:12)
at ReactReconcileTransaction.ReactInputSelection.getSelectionInformation (myapp/node_modules/react/lib/ReactInputSelection.js:40:23)
at ReactReconcileTransaction.Mixin.initializeAll (myapp/node_modules/react/lib/Transaction.js:168:30)
at ReactReconcileTransaction.Mixin.perform (myapp/node_modules/react/lib/Transaction.js:133:12)
at ReactUpdatesFlushTransaction.Mixin.perform (myapp/node_modules/react/lib/Transaction.js:134:20)
at ReactUpdatesFlushTransaction.assign.perform (myapp/node_modules/react/lib/ReactUpdates.js:95:38)
at Object.flushBatchedUpdates (myapp/node_modules/react/lib/ReactUpdates.js:175:19)
at Object.wrapper [as flushBatchedUpdates] (myapp/node_modules/react/lib/ReactPerf.js:70:21)
at ReactDefaultBatchingStrategyTransaction.Mixin.closeAll (myapp/node_modules/react/lib/Transaction.js:207:25)
at ReactDefaultBatchingStrategyTransaction.Mixin.perform (myapp/node_modules/react/lib/Transaction.js:148:16)
at Object.ReactDefaultBatchingStrategy.batchedUpdates (myapp/node_modules/react/lib/ReactDefaultBatchingStrategy.js:66:19)
at Object.enqueueUpdate (myapp/node_modules/react/lib/ReactUpdates.js:215:22)
at enqueueUpdate (myapp/node_modules/react/lib/ReactUpdateQueue.js:30:18)
at Object.ReactUpdateQueue.enqueueSetState (myapp/node_modules/react/lib/ReactUpdateQueue.js:208:5)
at [object Object].ReactComponent.setState (myapp/node_modules/react/lib/ReactComponent.js:69:20)
at Object.React.createElement.React.createElement.React.createElement.onChange (myapp/client/components/LoginForm.js:30:35)
Ideally, this module should realise it's running on the server, and skip this behaviour check