{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/4019","labels_url":"https://api.github.com/repos/facebook/react/issues/4019/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/4019/comments","events_url":"https://api.github.com/repos/facebook/react/issues/4019/events","html_url":"https://github.com/facebook/react/issues/4019","id":84653481,"number":4019,"title":"setState in shallowRender fails due to missing `document`","user":{"login":"glenjamin","id":151272,"avatar_url":"https://avatars.githubusercontent.com/u/151272?v=3","gravatar_id":"","url":"https://api.github.com/users/glenjamin","html_url":"https://github.com/glenjamin","followers_url":"https://api.github.com/users/glenjamin/followers","following_url":"https://api.github.com/users/glenjamin/following{/other_user}","gists_url":"https://api.github.com/users/glenjamin/gists{/gist_id}","starred_url":"https://api.github.com/users/glenjamin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glenjamin/subscriptions","organizations_url":"https://api.github.com/users/glenjamin/orgs","repos_url":"https://api.github.com/users/glenjamin/repos","events_url":"https://api.github.com/users/glenjamin/events{/privacy}","received_events_url":"https://api.github.com/users/glenjamin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react/labels/Component:%20Addons%20/%20TestUtils%20/%20Shallow%20Render","name":"Component: Addons / TestUtils / Shallow Render","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-06-03T16:35:27Z","updated_at":"2015-10-27T09:29:08Z","closed_at":null,"body":"Related to #2393 \r\n\r\nRendering a component like this:\r\n```jsx\r\n<div onClick={() => this.setState({something: 1}) />\r\n```\r\nrendering via shallow render, then calling handler\r\n```js\r\nvar result = shallowRenderer.getRenderOutput();\r\nresult.props.onClick()\r\n```\r\nProduces the following:\r\n```\r\n    ReferenceError: document is not defined\r\n      at getActiveElement (myapp/node_modules/react/lib/getActiveElement.js:23:12)\r\n      at ReactReconcileTransaction.ReactInputSelection.getSelectionInformation (myapp/node_modules/react/lib/ReactInputSelection.js:40:23)\r\n      at ReactReconcileTransaction.Mixin.initializeAll (myapp/node_modules/react/lib/Transaction.js:168:30)\r\n      at ReactReconcileTransaction.Mixin.perform (myapp/node_modules/react/lib/Transaction.js:133:12)\r\n      at ReactUpdatesFlushTransaction.Mixin.perform (myapp/node_modules/react/lib/Transaction.js:134:20)\r\n      at ReactUpdatesFlushTransaction.assign.perform (myapp/node_modules/react/lib/ReactUpdates.js:95:38)\r\n      at Object.flushBatchedUpdates (myapp/node_modules/react/lib/ReactUpdates.js:175:19)\r\n      at Object.wrapper [as flushBatchedUpdates] (myapp/node_modules/react/lib/ReactPerf.js:70:21)\r\n      at ReactDefaultBatchingStrategyTransaction.Mixin.closeAll (myapp/node_modules/react/lib/Transaction.js:207:25)\r\n      at ReactDefaultBatchingStrategyTransaction.Mixin.perform (myapp/node_modules/react/lib/Transaction.js:148:16)\r\n      at Object.ReactDefaultBatchingStrategy.batchedUpdates (myapp/node_modules/react/lib/ReactDefaultBatchingStrategy.js:66:19)\r\n      at Object.enqueueUpdate (myapp/node_modules/react/lib/ReactUpdates.js:215:22)\r\n      at enqueueUpdate (myapp/node_modules/react/lib/ReactUpdateQueue.js:30:18)\r\n      at Object.ReactUpdateQueue.enqueueSetState (myapp/node_modules/react/lib/ReactUpdateQueue.js:208:5)\r\n      at [object Object].ReactComponent.setState (myapp/node_modules/react/lib/ReactComponent.js:69:20)\r\n      at Object.React.createElement.React.createElement.React.createElement.onChange (myapp/client/components/LoginForm.js:30:35)\r\n```\r\n\r\nIdeally, this module should realise it's running on the server, and skip this behaviour check"},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/151428510","html_url":"https://github.com/facebook/react/issues/4019#issuecomment-151428510","issue_url":"https://api.github.com/repos/facebook/react/issues/4019","id":151428510,"user":{"login":"glenjamin","id":151272,"avatar_url":"https://avatars.githubusercontent.com/u/151272?v=3","gravatar_id":"","url":"https://api.github.com/users/glenjamin","html_url":"https://github.com/glenjamin","followers_url":"https://api.github.com/users/glenjamin/followers","following_url":"https://api.github.com/users/glenjamin/following{/other_user}","gists_url":"https://api.github.com/users/glenjamin/gists{/gist_id}","starred_url":"https://api.github.com/users/glenjamin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glenjamin/subscriptions","organizations_url":"https://api.github.com/users/glenjamin/orgs","repos_url":"https://api.github.com/users/glenjamin/repos","events_url":"https://api.github.com/users/glenjamin/events{/privacy}","received_events_url":"https://api.github.com/users/glenjamin/received_events","type":"User","site_admin":false},"created_at":"2015-10-27T09:29:08Z","updated_at":"2015-10-27T09:29:08Z","body":"For reference for future readers of this bug, the simplest current workaround I'm aware of is to do something like https://github.com/chantastic/react-media-object/commit/336112628be14b6fc6c50a10f7630110327dd108\r\n\r\nBasically, create a global document object to silence the warning before any tests are run.\r\n\r\n```js\r\nglobal.document = {}\r\n```"}}