Reputation: 1840
In my previous React project I was able to define propTypes before my constructor like this
static contextTypes = {
propToBePassed: React.PropTypes.object.isRequired
};
But in my new project WebPack is throwing an Unexpected token error with the carrot pointing to the = character.
Any idea what I'm missing?
Upvotes: 1
Views: 1096
Reputation: 35806
If you're exporting directly your class declaration and using Babel < 6.2, you'll have to separate it on two different lines like:
import { Component } from 'react'
class Button extends Component {}
export default Button
Depending on your versions, enable the classProperties
transform in your Babel options.
You could also look at the transform-class-properties babel docs which tells you to use the babel-plugin-transform-class-properties
module like Michelle said.
Upvotes: 2