{"action":"created","issue":{"url":"https://api.github.com/repos/goatslacker/alt/issues/283","labels_url":"https://api.github.com/repos/goatslacker/alt/issues/283/labels{/name}","comments_url":"https://api.github.com/repos/goatslacker/alt/issues/283/comments","events_url":"https://api.github.com/repos/goatslacker/alt/issues/283/events","html_url":"https://github.com/goatslacker/alt/issues/283","id":83491996,"number":283,"title":"Why this.setState is undefined in React ES6 class?","user":{"login":"theaqua","id":775692,"avatar_url":"https://avatars.githubusercontent.com/u/775692?v=3","gravatar_id":"","url":"https://api.github.com/users/theaqua","html_url":"https://github.com/theaqua","followers_url":"https://api.github.com/users/theaqua/followers","following_url":"https://api.github.com/users/theaqua/following{/other_user}","gists_url":"https://api.github.com/users/theaqua/gists{/gist_id}","starred_url":"https://api.github.com/users/theaqua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theaqua/subscriptions","organizations_url":"https://api.github.com/users/theaqua/orgs","repos_url":"https://api.github.com/users/theaqua/repos","events_url":"https://api.github.com/users/theaqua/events{/privacy}","received_events_url":"https://api.github.com/users/theaqua/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-06-01T13:22:30Z","updated_at":"2015-07-19T11:28:17Z","closed_at":"2015-06-01T13:45:55Z","body":"Hi, I trying to use ES6's classes for React (syntax as `class X extends React.Component`) and [alt.js](http://alt.js.org) as flux library. When something changed in my store, my view calls `onChange`, but it throws error `Uncaught TypeError: this.setState is not a function`.\r\n\r\nMy React component:\r\n\r\n    import React from 'react';\r\n    import { Router, Link } from 'react-router';\r\n\r\n    import PropertiesActions from '../../actions/properties';\r\n    import PropertiesStore from '../../stores/properties';\r\n    import PropertiesComponent from '../../components/properties/list';\r\n\r\n    // Module\r\n    class PropertiesView extends React.Component {\r\n      constructor(props) {\r\n        super(props);\r\n\r\n        this.state = PropertiesStore.getState();\r\n      }\r\n\r\n      componentDidMount() {\r\n        PropertiesStore.listen(this.onChange);\r\n\r\n        PropertiesActions.getList();\r\n      }\r\n\r\n      componentWillUnmount() {\r\n        PropertiesStore.unlisten(this.onChange);\r\n      }\r\n\r\n      onChange(state) {\r\n        this.setState(state);\r\n      }\r\n\r\n      render() {\r\n        return (<PropertiesComponent properties={this.state.properties} {...this.props} />)\r\n      }\r\n    };\r\n\r\n    PropertiesView.contextTypes = {\r\n      router: React.PropTypes.func\r\n    };\r\n\r\n    // Export\r\n    export default PropertiesView;"},"comment":{"url":"https://api.github.com/repos/goatslacker/alt/issues/comments/122650637","html_url":"https://github.com/goatslacker/alt/issues/283#issuecomment-122650637","issue_url":"https://api.github.com/repos/goatslacker/alt/issues/283","id":122650637,"user":{"login":"kiki-le-singe","id":2029646,"avatar_url":"https://avatars.githubusercontent.com/u/2029646?v=3","gravatar_id":"","url":"https://api.github.com/users/kiki-le-singe","html_url":"https://github.com/kiki-le-singe","followers_url":"https://api.github.com/users/kiki-le-singe/followers","following_url":"https://api.github.com/users/kiki-le-singe/following{/other_user}","gists_url":"https://api.github.com/users/kiki-le-singe/gists{/gist_id}","starred_url":"https://api.github.com/users/kiki-le-singe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiki-le-singe/subscriptions","organizations_url":"https://api.github.com/users/kiki-le-singe/orgs","repos_url":"https://api.github.com/users/kiki-le-singe/repos","events_url":"https://api.github.com/users/kiki-le-singe/events{/privacy}","received_events_url":"https://api.github.com/users/kiki-le-singe/received_events","type":"User","site_admin":false},"created_at":"2015-07-19T11:28:17Z","updated_at":"2015-07-19T11:28:17Z","body":"You can also use the following code by combining ES6 and ES7:\r\n\r\n> Note: Don't forget to setup Babel for this [babelify](https://www.npmjs.com/package/babelify#enable-experimental-transforms)\r\n\r\n```javascript\r\nonChange = (state) => {\r\n  this.setState(state);\r\n}\r\n```\r\n\r\nSee [React on ES6+](http://babeljs.io/blog/2015/06/07/react-on-es6-plus/) from Steven Luscher\r\n"}}