-1
I am making a form in React and this giving this error
'''
'''
TypeError: Cannot read property 'name' of undefined
UserCrud.updateField
48 |
49 | updateField(event) {
50 | const user = { ...this.state.user};
> 51 | user[user.target.name] = event.target.value; /* usa nome do input procura propriedade ,diz os atributos ,setou valor do input*/
52 | this.setState({ user }) /* passa user direto do ecma 2015 */
53 |
54 | }
View compiled
onChange
63 | <input type="text" className="form-control"
64 | name="name"
65 | value={this.state.user.name}
> 66 | onChange={e => this.updateField(e)}
| ^ 67 | placeholder="Digite o nome ..."/>
68 |
69 | </div>
View compiled
'''
Thank you brother was smashing his head
– Lutgens10