I am trying to create a component using ES2016 syntax as:
export default class {
static defaultProps = {
color: '#cc7f29',
}
}
I believe static defaultProps = {}
syntax is part of ES2016 so I loaded ES2016 preset into Babel. I have installed babel-preset-es2016
already.
This gives error in compilation:
Module build failed: SyntaxError: Unexpected token (10:22)
8 | export default class extends React.Component {
9 |
> 10 | static defaultProps = {
| ^
11 | color: '#cc7f29',
12 | theme: 'light',
13 | }
BabelLoaderError: SyntaxError: Unexpected token (10:22)
8 | export default class extends React.Component {
9 |
> 10 | static defaultProps = {
| ^
11 | color: '#cc7f29',
12 | theme: 'light',
13 | }
What am I doing wrong?