Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorators are not officially supported yet in 6.x pending a proposal update. #1

Open
ahyanarizky opened this issue Jan 27, 2017 · 1 comment

Comments

@ahyanarizky
Copy link

I got this error when i try to use your packages :

ERROR in ./src/app/home/index/sales/SalesInvoiceNew.js
Module build failed: SyntaxError: Decorators are not officially supported yet in 6.x pending a proposal update.
However, if you need to use them you can install the legacy decorators transform with:

npm install babel-plugin-transform-decorators-legacy --save-dev

and add the following line to your .babelrc file:

{
  "plugins": ["transform-decorators-legacy"]
}

The repo url is: https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy.

i have did what the error said, reset app and bundler (I am using webpack), but its not helping. Can you help?

here is my .babelrc :

{
    "presets": [
        "react",
        "es2015",
        "stage-0"
    ],
    "plugins": ["transform-decorators-legacy"] 
}

my models :

const activePolicy = Policy({
    test: props => props.expired_days > 0
})

@activePolicy
class createButtonActive extends Component {
    static propTypes = {
        expired_days: PropTypes.integer
    }

    render() {
        return (
            <RaisedButton onClick={this.createInvoice} label="Create" primary={true} labelStyle={{fontSize:'12px'}} />
        )
    }
}
@lucasconstantino
Copy link
Owner

It definitely does not seem to be related to react-policies, as the issue is clearly happening while compiling the code.

My advise would be for you to drop the usage of decorators, if it is not working on your build. Your could could be rewritten as follows:

const activePolicy = Policy({
    test: props => props.expired_days > 0
})

class createButtonActive extends Component {
    static propTypes = {
        expired_days: PropTypes.integer
    }

    render() {
        return (
            <RaisedButton onClick={this.createInvoice} label="Create" primary={true} labelStyle={{fontSize:'12px'}} />
        )
    }
}

export default activePolicy(createButtonActive)

If I have the time, I'll try and simulate the issue locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants