I use the React to write this demo. I use the Webpack to build this demo.When I start this demo, the error will show me.
ERROR in ./src/app.js Module build failed: SyntaxError: Unexpected token (8:24)
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
class Button extends Component {
constructor(props){
super(props);
}
static defaultProps = {
color:'blue',
text: 'Confirm',
}
render (){
return (
<button className={'btn btn-${color}'}>
<em>{text}</em>
<p>This is a button.</p>
</button>
);
}
}
ReactDOM.render(<Button />, document.getElementById('app'));
I read this demo from a book. Due to the book is probably print the wrong code. So I ask this question now.
The error show static defaultProps = {
is not right. The book is also written with this form. Do you know the right code?