andreypopp / autobind-decorator

Decorator to automatically bind methods to class instances
MIT License
1.45k stars 66 forks source link

Uncaught TypeError: decorator is not a function #56

Closed gautier-lefebvre closed 7 years ago

gautier-lefebvre commented 7 years ago

With the latest release 1.4.4, we get an error when using the autobind on a method, and building with webpack and babel-plugin-transform-decorators-legacy:

class Suggestion extends PureComponent {
    @autobind
    _onClick() {
        return this.props.onClick(this.props.suggestion);
    }
    ...
}

inside _applyDecoratedDescriptor (from webpack plugin) ->

Uncaught TypeError: decorator is not a function
longlho commented 7 years ago

I believe babel 6 (maybe 7) no longer retrofits module.exports, so if ur using autobind via require u'd have to do require('autobind-decorator').default

gautier-lefebvre commented 7 years ago

Yeah you're probably right, but that's a breaking change, since previous versions were working fine with babel 6. That would be great if you released these changes as a new major version.

longlho commented 7 years ago

@stevemao ^^

stevemao commented 7 years ago

unpublished 1.4.4 and published 2.0.0.