2
I have the following error when I try to use Component in this way.
client?cd17:119 ./src/App/Components/AddNote.js
Module build failed: SyntaxError: super() outside of class constructor (9:4)
7 | const FormText = React.createClass({
8 | constructor(props) {
> 9 | super(props)
| ^
10 | this.state = { title: '', note: ''}
11 |
12 | this.handleChange = this.handleChange.bind(this)
@ ./src/App/App.js 17:15-46
@ ./src/index.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index
But if I use this other way I can pass normally the properties to constructor. Can anyone tell me what mistake I’m making?
class AddForm extends React.Component {
constructor(props) {
super(props);
this.state = {title: '', note: ''};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({title: event.target.value, note: event.target.value});
}
handleSubmit(event) {
alert('Os dados foram submetidos' + this.state.title +' e '+ this.state.note);
event.preventDefault();
}