Tenho o seguinte erro quando tento utilizar o component desta forma.
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
Mas se eu utilizar desta outra forma consigo passar normalmente as propriedades para construtor.Alguém consegue me dizer qual erro estou cometendo?
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();
}