{"action":"created","issue":{"url":"https://api.github.com/repos/reactjs/react-modal/issues/260","repository_url":"https://api.github.com/repos/reactjs/react-modal","labels_url":"https://api.github.com/repos/reactjs/react-modal/issues/260/labels{/name}","comments_url":"https://api.github.com/repos/reactjs/react-modal/issues/260/comments","events_url":"https://api.github.com/repos/reactjs/react-modal/issues/260/events","html_url":"https://github.com/reactjs/react-modal/issues/260","id":185974239,"number":260,"title":"[v1.5.2] Is it possible to use `Modal.setAppElement` with SSR ?","user":{"login":"DimaRGB","id":2676086,"avatar_url":"https://avatars2.githubusercontent.com/u/2676086?v=4","gravatar_id":"","url":"https://api.github.com/users/DimaRGB","html_url":"https://github.com/DimaRGB","followers_url":"https://api.github.com/users/DimaRGB/followers","following_url":"https://api.github.com/users/DimaRGB/following{/other_user}","gists_url":"https://api.github.com/users/DimaRGB/gists{/gist_id}","starred_url":"https://api.github.com/users/DimaRGB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DimaRGB/subscriptions","organizations_url":"https://api.github.com/users/DimaRGB/orgs","repos_url":"https://api.github.com/users/DimaRGB/repos","events_url":"https://api.github.com/users/DimaRGB/events{/privacy}","received_events_url":"https://api.github.com/users/DimaRGB/received_events","type":"User","site_admin":false},"labels":[{"id":540534526,"url":"https://api.github.com/repos/reactjs/react-modal/labels/needs%20info","name":"needs info","color":"fef2c0","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-28T17:10:46Z","updated_at":"2018-04-22T19:46:42Z","closed_at":"2017-06-17T15:50:44Z","author_association":"NONE","body":"When i try to use `Modal.setAppElement` just before declare some ContainerComponent:\n\n```\nReactModal.setAppElement('#app');\nclass ContainerComponent extends React.Component {\n  render() {\n    return (\n      <Modal {...} />\n    );\n  }\n}\n```\n\ni have next error:\n\n```\nreact-modal/lib/helpers/ariaAppHider.js:5\n var el = document.querySelectorAll(element);\n              ^\n\n ReferenceError: document is not defined\n```\n"},"comment":{"url":"https://api.github.com/repos/reactjs/react-modal/issues/comments/383407288","html_url":"https://github.com/reactjs/react-modal/issues/260#issuecomment-383407288","issue_url":"https://api.github.com/repos/reactjs/react-modal/issues/260","id":383407288,"user":{"login":"NathanielHill","id":15079979,"avatar_url":"https://avatars1.githubusercontent.com/u/15079979?v=4","gravatar_id":"","url":"https://api.github.com/users/NathanielHill","html_url":"https://github.com/NathanielHill","followers_url":"https://api.github.com/users/NathanielHill/followers","following_url":"https://api.github.com/users/NathanielHill/following{/other_user}","gists_url":"https://api.github.com/users/NathanielHill/gists{/gist_id}","starred_url":"https://api.github.com/users/NathanielHill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NathanielHill/subscriptions","organizations_url":"https://api.github.com/users/NathanielHill/orgs","repos_url":"https://api.github.com/users/NathanielHill/repos","events_url":"https://api.github.com/users/NathanielHill/events{/privacy}","received_events_url":"https://api.github.com/users/NathanielHill/received_events","type":"User","site_admin":false},"created_at":"2018-04-22T19:46:42Z","updated_at":"2018-04-22T19:46:42Z","author_association":"NONE","body":"For reference, since it was a pain for me, if you are doing SSR, use the following code to prevent errors server-side:\r\n\r\n    if (typeof(window) !== 'undefined') {\r\n        ReactModal.setAppElement('body')\r\n    }\r\n\r\nYou could put this in `componentDidMount()` anywhere you use a modal or I put it in a custom modal component so it's nice and DRY.\r\n\r\n  #580"}}
{"actor":{"display_login":"NathanielHill"}}