{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel/issues/1161","labels_url":"https://api.github.com/repos/babel/babel/issues/1161/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/1161/comments","events_url":"https://api.github.com/repos/babel/babel/issues/1161/events","html_url":"https://github.com/babel/babel/issues/1161","id":66364249,"number":1161,"title":"React Component is not working with class decorators","user":{"login":"Dignifiedquire","id":790842,"avatar_url":"https://avatars.githubusercontent.com/u/790842?v=3","gravatar_id":"","url":"https://api.github.com/users/Dignifiedquire","html_url":"https://github.com/Dignifiedquire","followers_url":"https://api.github.com/users/Dignifiedquire/followers","following_url":"https://api.github.com/users/Dignifiedquire/following{/other_user}","gists_url":"https://api.github.com/users/Dignifiedquire/gists{/gist_id}","starred_url":"https://api.github.com/users/Dignifiedquire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dignifiedquire/subscriptions","organizations_url":"https://api.github.com/users/Dignifiedquire/orgs","repos_url":"https://api.github.com/users/Dignifiedquire/repos","events_url":"https://api.github.com/users/Dignifiedquire/events{/privacy}","received_events_url":"https://api.github.com/users/Dignifiedquire/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/babel/babel/labels/invalid","name":"invalid","color":"e6e6e6"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-04-04T20:38:23Z","updated_at":"2015-04-05T06:51:51Z","closed_at":null,"body":"I was very excited for the new decorator syntax and was trying to get a simple example of class decorators with react working. Unfortunately I'm running into the following issue:\r\n\r\nUsing this simple component\r\n```js\r\n@Enhance\r\nexport class Simple extends Component {\r\n\r\n  render() {\r\n    return (\r\n      <span>I am a {this.props.enhanced ? 'enhanced' : 'simple'} component.</span>\r\n    )\r\n  }\r\n}\r\n```\r\n\r\nand this `Enhance` decorator\r\n\r\n```js\r\nimport React from 'react'\r\nconst { Component } = React\r\n\r\nconst Enhance = Target => class extends Component {\r\n\r\n  render() {\r\n    return <Target {...this.props} enhanced={true} />\r\n  }\r\n}\r\n```\r\nIf I try to render this component it throws with\r\n\r\n```\r\nUncaught TypeError: Cannot call a class as a function  bundle.js:58 \r\n_classCallCheck                                        bundle.js:101\r\n```\r\n\r\nThe generated `bundle.js` can be found [here](https://gist.github.com/Dignifiedquire/e5244904712f94f9c05c)\r\n\r\n\r\nIt seems that the check for the constructor of the `Simple` component is referencing the constructor where `Enhance` has already been applied to.\r\n\r\nI might be just doing  something wrong, if so a pointer to what I need to fix would be great. \r\n\r\nThanks for a great tool!\r\n\r\n\r\n---\r\n\r\nLibraries used:\r\n```bash\r\n➜  react  npm ls react\r\n/Users/dignifiedquire/play/react\r\n└── react@0.13.1\r\n\r\n➜  react  npm ls babel-loader\r\n/Users/dignifiedquire/play/react\r\n└── babel-loader@5.0.0\r\n\r\n➜  react  npm ls babel-core\r\n/Users/dignifiedquire/play/react\r\n├── babel-core@5.0.8\r\n└─┬ babel-loader@5.0.0\r\n  └── babel-core@5.0.8\r\n```"},"comment":{"url":"https://api.github.com/repos/babel/babel/issues/comments/89729287","html_url":"https://github.com/babel/babel/issues/1161#issuecomment-89729287","issue_url":"https://api.github.com/repos/babel/babel/issues/1161","id":89729287,"user":{"login":"Dignifiedquire","id":790842,"avatar_url":"https://avatars.githubusercontent.com/u/790842?v=3","gravatar_id":"","url":"https://api.github.com/users/Dignifiedquire","html_url":"https://github.com/Dignifiedquire","followers_url":"https://api.github.com/users/Dignifiedquire/followers","following_url":"https://api.github.com/users/Dignifiedquire/following{/other_user}","gists_url":"https://api.github.com/users/Dignifiedquire/gists{/gist_id}","starred_url":"https://api.github.com/users/Dignifiedquire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dignifiedquire/subscriptions","organizations_url":"https://api.github.com/users/Dignifiedquire/orgs","repos_url":"https://api.github.com/users/Dignifiedquire/repos","events_url":"https://api.github.com/users/Dignifiedquire/events{/privacy}","received_events_url":"https://api.github.com/users/Dignifiedquire/received_events","type":"User","site_admin":false},"created_at":"2015-04-05T06:51:51Z","updated_at":"2015-04-05T06:51:51Z","body":"Sure, I will try to find out more if I can in the meantime, so far I was able to reduce it down to this minimal example:\r\n\r\n\r\n```js\r\nfunction F(Target) {\r\n  // Calling `new Target()` here works fine\r\n  return () => {\r\n    target: new Target() // This breaks things\r\n  }\r\n}\r\n\r\nvar Foo = (function () {\r\n  class Foo {\r\n    constructor() {}\r\n  }\r\n\r\n  Foo = F(Foo) || Foo;\r\n  return Foo;\r\n})();\r\n\r\n\r\n@F\r\nclass Bar {\r\n  constructor() {}\r\n}\r\n\r\nconst foo = new Foo()\r\nconst bar = new Bar()  // Throws `Cannot call a class as a function`\r\n\r\n```\r\n\r\nThe error only happens when `new Target()` is executed inside the returned value of the decorator."}}