Quando tento rodar o dev-server ele me retorna um erro no console que eu não consigo identificar o que está gerando ele
webpack.config.js
iconst path = require('path');
module.exports = {
entry: './src/app.js',
output: {
path: path.join(__dirname,'public'),
filename: 'bundle.js'
},
module: {
rules: [{
loader: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
},]
},
devtool: 'cheap-module-evel-source-map',
devServer: {
contentBase:path.join(__dirname,'public'),
historyApiFallback: true
}
};
Arquivo que da erro
import React from 'react';
class FormCadastroUser extends React.Component {
constructor(props){
super(props);
this.onEmailChange = this.onEmailChange.bind(this);
this.onNameChange = this.onNameChange.bind(this);
this.onLastNameChange = this.onLastNameChange.bind(this);
this.onPasswordChange = this.onPasswordChange.bind(this);
this.onSubmit = this.onSubmit.bind(this);
this.state={
name: '',
lastname: '',
email: '',
password: ''
}
}
onNameChange = (e) => {
const name = e.target.value;
this.setState(() => ({name}));
}
onLastNameChange = (e) => {
const lastname = e.target.value;
this.setState(() => ({lastname}));
}
onEmailChange = (e) => {
const email = e.target.value;
this.setState(() => ({email}));
}
onPasswordChange = (e) => {
const password = e.target.value;
this.setState(() => ({password}));
}
onSubmit = (e) => {
e.preventDefaut();
this.props.onSubmit({
name: this.state.name,
lastname: this.state.lastname,
email: this.state.email,
password: this.state.password
});
}
render(){
return (
<div className= 'container'>
<form onSubmit={this.onSubmit}>
<div className="form-row">
<div className="col">
<input type="text" className="form-control" placeholder="First name" autoFocus value={this.state.name} onChange={this.onNameChange} />
</div>
<div className="col">
<input type="text" className="form-control" placeholder="Last name" value={this.state.lastname} onChange={this.onLastNameChange}/>
</div>
<div className="col">
<input type="Email" className="form-control" placeholder="Email" value={this.state.email} onChange={this.onEmailChange}/>
</div>
<div className="col">
<input type="text" className="form-control" placeholder="Password" value={this.state.password} onChange={this.onPasswordChange}/>
</div>
</div>
<div style={{paddingTop: '10px'}}>
<button type="submit" className="btn btn-primary">Sign in</button>
</div>
</form>
</div>
);
}
}
export default FormCadastroUser;
O erro acusa no
onNameChange = (e) => {
| ^
no sinal de Igual.