{"action":"created","issue":{"url":"https://api.github.com/repos/rackt/react-router/issues/2543","labels_url":"https://api.github.com/repos/rackt/react-router/issues/2543/labels{/name}","comments_url":"https://api.github.com/repos/rackt/react-router/issues/2543/comments","events_url":"https://api.github.com/repos/rackt/react-router/issues/2543/events","html_url":"https://github.com/rackt/react-router/issues/2543","id":116749832,"number":2543,"title":"onEnter accessing state from some sort of routing context","user":{"login":"mehcode","id":753919,"avatar_url":"https://avatars.githubusercontent.com/u/753919?v=3","gravatar_id":"","url":"https://api.github.com/users/mehcode","html_url":"https://github.com/mehcode","followers_url":"https://api.github.com/users/mehcode/followers","following_url":"https://api.github.com/users/mehcode/following{/other_user}","gists_url":"https://api.github.com/users/mehcode/gists{/gist_id}","starred_url":"https://api.github.com/users/mehcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mehcode/subscriptions","organizations_url":"https://api.github.com/users/mehcode/orgs","repos_url":"https://api.github.com/users/mehcode/repos","events_url":"https://api.github.com/users/mehcode/events{/privacy}","received_events_url":"https://api.github.com/users/mehcode/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-13T11:20:29Z","updated_at":"2015-11-13T13:24:14Z","closed_at":"2015-11-13T13:22:41Z","body":"I'm working with [alt](https://github.com/goatslacker/alt) and attempting to access an alt instance (just think magic variable that is instantiated just before I render the `Router` component). I'm wondering how to get said magic variable into an `onEnter` call (considering server-side rendering and that magic variable being able to be set locally and not globally).\r\n\r\n**render**\r\n```jsx\r\nvar magic = {isAuthenticated: false}\r\n\r\n// pass in magic somewhere\r\nReactDOM.render(\r\n  <Router\r\n    history={createBrowserHistory()}\r\n    routes={routes}\r\n    {/* Doesn't work but illustrates what I'm thinking I want */}\r\n    context={magic}\r\n  />,\r\ndocument.getElementById(\"root\"))\r\n```\r\n\r\n**routes**\r\n```jsx\r\nfunction requireAuth(nextState, replaceState) {\r\n  const magic = getMagicSomehow()\r\n  if (!magic.isAuthenticated) {\r\n    replaceState({next: nextState.location.pathname}, \"/login\")\r\n  }\r\n}\r\n\r\nexport default (\r\n  <Route path=\"/\">\r\n    <Route path=\"login\" component={Login} />\r\n\r\n    <Route onEnter={requireAuth}>\r\n      <IndexRoute component={Index} />\r\n    </Route>\r\n  </Route>\r\n)\r\n```\r\n\r\n---\r\n\r\nAny help in the right direction to write `getMagicSomehow` would be appreciated.\r\n\r\n---\r\n\r\nCross-posted (from a different perspective) to https://github.com/goatslacker/alt/issues/541"},"comment":{"url":"https://api.github.com/repos/rackt/react-router/issues/comments/156430787","html_url":"https://github.com/rackt/react-router/issues/2543#issuecomment-156430787","issue_url":"https://api.github.com/repos/rackt/react-router/issues/2543","id":156430787,"user":{"login":"knowbody","id":3802023,"avatar_url":"https://avatars.githubusercontent.com/u/3802023?v=3","gravatar_id":"","url":"https://api.github.com/users/knowbody","html_url":"https://github.com/knowbody","followers_url":"https://api.github.com/users/knowbody/followers","following_url":"https://api.github.com/users/knowbody/following{/other_user}","gists_url":"https://api.github.com/users/knowbody/gists{/gist_id}","starred_url":"https://api.github.com/users/knowbody/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knowbody/subscriptions","organizations_url":"https://api.github.com/users/knowbody/orgs","repos_url":"https://api.github.com/users/knowbody/repos","events_url":"https://api.github.com/users/knowbody/events{/privacy}","received_events_url":"https://api.github.com/users/knowbody/received_events","type":"User","site_admin":false},"created_at":"2015-11-13T13:24:14Z","updated_at":"2015-11-13T13:24:14Z","body":"@taion boom :boom: "}}