Skip to content Skip to sidebar Skip to footer

ECMA7 Static Prototypes Is Not Yet Supported In Meteor, What Is A Good Workaround?

I would like to use ECMA static proptypes within my React code. Unfortunately this throws the following Babel error Missing class properties transform.. As far as I'm aware this i

Solution 1:

Just manually assign the static properties instead of declaring them in the class body (which is not supported in ES7):

export default class BookListingTable extends TrackerReact(React.Component) {
    …
}
BookListingTable.propTypes = {
    LimitProp: React.PropTypes.number.isRequired
};
BookListingTable.defaultProps = {
    LimitProp: 5
};

Solution 2:

There is a better approach today, it makes you use static.

add the following package:

meteor npm install --save-dev babel-plugin-transform-class-properties

Edit your package.json in your project and add there the following to make the package work:

 "babel": {
    "plugins": ["transform-class-properties"]

  }

Post a Comment for "ECMA7 Static Prototypes Is Not Yet Supported In Meteor, What Is A Good Workaround?"