{"action":"created","issue":{"url":"https://api.github.com/repos/stampit-org/react-stampit/issues/9","labels_url":"https://api.github.com/repos/stampit-org/react-stampit/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/stampit-org/react-stampit/issues/9/comments","events_url":"https://api.github.com/repos/stampit-org/react-stampit/issues/9/events","html_url":"https://github.com/stampit-org/react-stampit/issues/9","id":88131529,"number":9,"title":"\"this\" undefined","user":{"login":"fcmatteo","id":1399253,"avatar_url":"https://avatars.githubusercontent.com/u/1399253?v=3","gravatar_id":"","url":"https://api.github.com/users/fcmatteo","html_url":"https://github.com/fcmatteo","followers_url":"https://api.github.com/users/fcmatteo/followers","following_url":"https://api.github.com/users/fcmatteo/following{/other_user}","gists_url":"https://api.github.com/users/fcmatteo/gists{/gist_id}","starred_url":"https://api.github.com/users/fcmatteo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fcmatteo/subscriptions","organizations_url":"https://api.github.com/users/fcmatteo/orgs","repos_url":"https://api.github.com/users/fcmatteo/repos","events_url":"https://api.github.com/users/fcmatteo/events{/privacy}","received_events_url":"https://api.github.com/users/fcmatteo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-14T06:25:56Z","updated_at":"2015-06-14T15:01:51Z","closed_at":null,"body":"Hi, I am trying to use the library to make an isomorphic application. I have a component like this:\r\n\r\n```javascript\r\nconst CreateComponent = stampit(React, {\r\n  state: {\r\n    text: 'something'\r\n  },\r\n\r\n  changeState: function(event) {\r\n    console.log(this.state.text);\r\n  },\r\n\r\n  render: function() {\r\n    return (\r\n      <input type='button' defaultValue={this.state.text} onClick={this.changeState} />\r\n    );\r\n  }\r\n});\r\n```\r\n\r\nIt renders, both server and client side, but when I click on it I receive this error `Uncaught TypeError: Cannot read property 'state' of undefined`.\r\n\r\nI am rendering server-side like this\r\n\r\n```javascript\r\nvar CreateComponent = React.createFactory(require('../app/components/CreateComponent.jsx'));\r\nrouter.get('/component/create/', function (req, res, next) {\r\n\r\n  let createComponentReact = React.renderToString(CreateComponent({}));\r\n  res.render('admin/createComponent',\r\n    { title: 'Title',\r\n      createComponentReact: createComponentReact });\r\n});\r\n```\r\n\r\nAnd client-side like this\r\n\r\n```javascript\r\nvar CreateComponent = require('./components/CreateComponent.jsx');\r\n\r\nReact.render(\r\n  <CreateComponent />,\r\n  document.getElementById('CreateComponent')\r\n);\r\n```"},"comment":{"url":"https://api.github.com/repos/stampit-org/react-stampit/issues/comments/111837958","html_url":"https://github.com/stampit-org/react-stampit/issues/9#issuecomment-111837958","issue_url":"https://api.github.com/repos/stampit-org/react-stampit/issues/9","id":111837958,"user":{"login":"troutowicz","id":8117994,"avatar_url":"https://avatars.githubusercontent.com/u/8117994?v=3","gravatar_id":"","url":"https://api.github.com/users/troutowicz","html_url":"https://github.com/troutowicz","followers_url":"https://api.github.com/users/troutowicz/followers","following_url":"https://api.github.com/users/troutowicz/following{/other_user}","gists_url":"https://api.github.com/users/troutowicz/gists{/gist_id}","starred_url":"https://api.github.com/users/troutowicz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troutowicz/subscriptions","organizations_url":"https://api.github.com/users/troutowicz/orgs","repos_url":"https://api.github.com/users/troutowicz/repos","events_url":"https://api.github.com/users/troutowicz/events{/privacy}","received_events_url":"https://api.github.com/users/troutowicz/received_events","type":"User","site_admin":false},"created_at":"2015-06-14T15:01:51Z","updated_at":"2015-06-14T15:01:51Z","body":"@fcmatteo Thank you for reporting this unexpected, while correct behavior. The reason this does not work is because of my naive understanding of `this` and what React's autobinding actually did in `.createClass`.\r\n\r\n In JS, function calls are late bound. This means that the meaning of `this` inside a function may not be what you expect after passing the function around. React's autobinding handled this behavior automatically for non-React methods in `.createClass`.\r\n\r\nWe could implement magical autobinding for react-stampit, but I don't want to. I want the user to be in control, and be aware of how JS works instead of relying on magic to make things cognitively simpler.\r\n\r\nI will update the README soon with a more appropriate example.\r\n\r\n"}}