{"action":"opened","issue":{"url":"https://api.github.com/repos/rackt/redux-router/issues/115","labels_url":"https://api.github.com/repos/rackt/redux-router/issues/115/labels{/name}","comments_url":"https://api.github.com/repos/rackt/redux-router/issues/115/comments","events_url":"https://api.github.com/repos/rackt/redux-router/issues/115/events","html_url":"https://github.com/rackt/redux-router/issues/115","id":111012880,"number":115,"title":"Reducer \"router\" returns undefined during server-side rendering","user":{"login":"axelander","id":3784741,"avatar_url":"https://avatars.githubusercontent.com/u/3784741?v=3","gravatar_id":"","url":"https://api.github.com/users/axelander","html_url":"https://github.com/axelander","followers_url":"https://api.github.com/users/axelander/followers","following_url":"https://api.github.com/users/axelander/following{/other_user}","gists_url":"https://api.github.com/users/axelander/gists{/gist_id}","starred_url":"https://api.github.com/users/axelander/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axelander/subscriptions","organizations_url":"https://api.github.com/users/axelander/orgs","repos_url":"https://api.github.com/users/axelander/repos","events_url":"https://api.github.com/users/axelander/events{/privacy}","received_events_url":"https://api.github.com/users/axelander/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-12T16:41:28Z","updated_at":"2015-10-12T16:41:28Z","closed_at":null,"body":"Hey!\r\n\r\nI'm having an issue while doing server-side rendering of my application. \r\nI get the following error message:\r\n```js\r\nError: Reducer \"router\" returned undefined handling \"@@reduxReactRouter/routerDidChange\". To ignore an action, you must explicitly return the previous state.\r\n```\r\n\r\nAfter doing some digging it seems like, in the routerStateReducer, the action.payload is undefined at one point. When I change line 17 to:\r\n```js\r\nreturn action.payload !== undefined ? action.payload : null;\r\n```\r\neverything works without errors on the server and the client. I'm guessing this patch is not needed and I'm doing something else wrong but I can't figure out what.\r\n\r\nServer (only the parts involved in rendering the app):\r\n```js\r\nconst reducer = combineReducers(reducers);\r\nconst store = compose(\r\n  reduxReactRouter({ routes }),\r\n  applyMiddleware(thunk)\r\n)(createStore)(reducer);\r\n\r\nconst query = qs.stringify(req.query);\r\nconst url = req.path + (query.length ? '?' + query : '');\r\n\r\nstore.dispatch(match(url, (err, redirectLocation, renderProps) => {\r\n  const InitialView = (\r\n     <Provider store={store}>\r\n      <ReduxRouter />\r\n    </Provider>\r\n  );\r\n\r\n  const componentHTML = renderToString(InitialView);\r\n  const initialState = store.getState();\r\n\r\n  const HTML = `\r\n    <!DOCTYPE html>\r\n    <html>\r\n     <head>\r\n      <meta charset=\"utf-8\">\r\n      <title>${req.hostname}</title>\r\n\r\n      <script type=\"application/javascript\">\r\n        window.__INITIAL_STATE__ = ${JSON.stringify(initialState)};\r\n      </script>\r\n        <link rel=\"stylesheet\" type=\"text/css\" href=\"/assets/styles.css\" />\r\n      </head>\r\n      <body>\r\n        <div id=\"react-root\">${componentHTML}</div>\r\n        <script type=\"application/javascript\" src=\"/assets/bundle.js\"></script>\r\n      </body>\r\n    </html>\r\n  `;\r\n\r\n  res.end(html);\r\n}));\r\n```\r\n\r\nRoutes:\r\n```js\r\nimport React from 'react';\r\nimport { Route } from 'react-router';\r\n\r\nimport Application from './views/Application';\r\nimport Index from './views/Index';\r\nimport Article from './views/Article';\r\n\r\nexport default (\r\n  <Route name=\"app\" component={Application}>\r\n    <Route component={Index} path=\"/\" />\r\n    <Route component={Article} path=\"/article/:slug\" />\r\n  </Route>\r\n);\r\n```\r\n\r\nReducers:\r\n```js\r\nimport config from './ConfigReducer';\r\nimport menu from './MenuReducer';\r\nimport articles from './ArticlesReducer';\r\nimport { routerStateReducer as router } from 'redux-router';\r\nexport {\r\n  config,\r\n  menu,\r\n  articles,\r\n  router\r\n}\r\n```"}}