{"action":"created","issue":{"url":"https://api.github.com/repos/alexmingoia/koa-router/issues/269","repository_url":"https://api.github.com/repos/alexmingoia/koa-router","labels_url":"https://api.github.com/repos/alexmingoia/koa-router/issues/269/labels{/name}","comments_url":"https://api.github.com/repos/alexmingoia/koa-router/issues/269/comments","events_url":"https://api.github.com/repos/alexmingoia/koa-router/issues/269/events","html_url":"https://github.com/alexmingoia/koa-router/issues/269","id":151373011,"number":269,"title":"this.state props is undefined after rendering","user":{"login":"zombofrog","id":12626649,"avatar_url":"https://avatars.githubusercontent.com/u/12626649?v=3","gravatar_id":"","url":"https://api.github.com/users/zombofrog","html_url":"https://github.com/zombofrog","followers_url":"https://api.github.com/users/zombofrog/followers","following_url":"https://api.github.com/users/zombofrog/following{/other_user}","gists_url":"https://api.github.com/users/zombofrog/gists{/gist_id}","starred_url":"https://api.github.com/users/zombofrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zombofrog/subscriptions","organizations_url":"https://api.github.com/users/zombofrog/orgs","repos_url":"https://api.github.com/users/zombofrog/repos","events_url":"https://api.github.com/users/zombofrog/events{/privacy}","received_events_url":"https://api.github.com/users/zombofrog/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-04-27T12:28:51Z","updated_at":"2016-12-11T01:07:58Z","closed_at":"2016-12-11T01:07:58Z","body":"Here is my server: \n\n```\nvar app = require('koa')();\nvar router = require('koa-router')();\n\nvar port = 3003;\n\nrouter.get('home', '/', function * (next) {\n  this.state.props = { page: 'home' };\n  yield next;\n});\n\napp.use(router.routes())\n   .use(router.allowedMethods())\n   .use(function * () {\n     console.log('log: ', this.state);\n     this.body = this.state.props.page;\n   });\n\napp.listen(port);\n```\n\nAll works correctly, but after rendering '/' page I got a such error in console:\n\n```\nlog:  { props: { page: 'home' } }\nlog:  {}\n\n  TypeError: Cannot read property 'page' of undefined\n      at Object.<anonymous> (c:\\Boxes\\projects\\react-server-side\\bin\\server.js:15:34)\n      at next (native)\n      at Object.allowedMethods (c:\\Boxes\\projects\\react-server-side\\node_modules\\koa-router\\lib\\router.js:374:12)\n      at next (native)\n      at Object.dispatch (c:\\Boxes\\projects\\react-server-side\\node_modules\\koa-router\\lib\\router.js:336:14)\n      at next (native)\n      at Object.<anonymous> (c:\\Boxes\\projects\\react-server-side\\node_modules\\koa\\node_modules\\koa-compose\\index.js:28:19)\n      at next (native)\n      at onFulfilled (c:\\Boxes\\projects\\react-server-side\\node_modules\\koa\\node_modules\\co\\index.js:65:19)\n      at c:\\Boxes\\projects\\react-server-side\\node_modules\\koa\\node_modules\\co\\index.js:54:5\n```\n\nWhy last generator calls second time whiout my props in ctx.state?\n"},"comment":{"url":"https://api.github.com/repos/alexmingoia/koa-router/issues/comments/266253731","html_url":"https://github.com/alexmingoia/koa-router/issues/269#issuecomment-266253731","issue_url":"https://api.github.com/repos/alexmingoia/koa-router/issues/269","id":266253731,"user":{"login":"jbielick","id":1413330,"avatar_url":"https://avatars.githubusercontent.com/u/1413330?v=3","gravatar_id":"","url":"https://api.github.com/users/jbielick","html_url":"https://github.com/jbielick","followers_url":"https://api.github.com/users/jbielick/followers","following_url":"https://api.github.com/users/jbielick/following{/other_user}","gists_url":"https://api.github.com/users/jbielick/gists{/gist_id}","starred_url":"https://api.github.com/users/jbielick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbielick/subscriptions","organizations_url":"https://api.github.com/users/jbielick/orgs","repos_url":"https://api.github.com/users/jbielick/repos","events_url":"https://api.github.com/users/jbielick/events{/privacy}","received_events_url":"https://api.github.com/users/jbielick/received_events","type":"User","site_admin":false},"created_at":"2016-12-11T01:07:58Z","updated_at":"2016-12-11T01:07:58Z","body":"What version of koa, koa-router are you using? \r\n\r\nI created a simple test case for this that looks like the following:\r\n\r\n```js\r\nvar koa = require('koa')\r\nvar app = new koa();\r\nvar router = require('koa-router')();\r\nvar assert = require('assert');\r\nvar request = require('supertest');\r\n\r\nrouter.get('home', '/', function * (next) {\r\n  this.state.props = { page: 'home' };\r\n  yield next;\r\n});\r\n\r\napp.use(router.routes())\r\n   .use(router.allowedMethods())\r\n   .use(function * () {\r\n     this.body = this.state.props.page;\r\n   });\r\n\r\nrequest(app.listen())\r\n  .get('/')\r\n  .expect(200)\r\n  .end((err, res) => {\r\n    assert(res.text == 'home');\r\n    process.exit(0);\r\n  });\r\n\r\n```\r\n\r\n```json\r\n    \"koa\": \"1.2.4\",\r\n    \"koa-router\": \"5.4.0\",\r\n    \"supertest\": \"2.0.0\"\r\n```\r\n\r\nand it works just fine."}}
{"actor":{"display_login":"jbielick"}}