1

I follow this example

react set state in for nested state

to set nested state in react. What's wrong with below code? I want e.target.name as the property of the object.

onChange = (e) => {
    this.setState({
        input: {...this.state.input, e.target.name: e.target.value}
    })
  }

https://codesandbox.io/s/qqwokzzym9

Thian Kian Phin
  • 921
  • 3
  • 13
  • 25

0 Answers0