How do I edit multiple input controlled components in React?

后端 未结 9 536
[愿得一人]
[愿得一人] 2020-12-04 09:01

I have a component that stores a contact object as state - {firstName: \"John\", lastName: \"Doe\", phone: \"1234567890} I want to create a form to edit this object but if I

9条回答
  •  我在风中等你
    2020-12-04 09:46

    You can do it without duplicate code and easy way

    handleChange=(e)=>{
        this.setState({
            [e.target.id]:e.target.value
        })
    }
    
    
    
    
    

提交回复
热议问题