我正在尝试使用状态来隐藏语义 UI 模型表单,并将 JSON 传递给 Customer 类以添加新客户。我能够传递该值,但最终只有一个值。
当我开始输入名称时,在控制台面板中,第一个字符名称为空“”,第二个字符上有单个“a”

当我单击“创建”按钮时,名称为空“”并且地址具有值。
import React from 'react';
import { Button, Form, Modal } from 'semantic-ui-react';
export default class AddCustomer extends React.Component {
constructor(props) {
super(props);
this.state = {
showCreateForm:false,
formData:{
name: '',
address: ''
}
}
this.handleChangeName = this.handleChangeName.bind(this);
this.handleChangeAddress = this.handleChangeAddress.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChangeName(event) {
const value = event.target.value;
console.log(value);
this.setState({formData:{name:value}});
//when i go to add input the formData is still empty name is empty.
//name: ""
//address: "" …Run Code Online (Sandbox Code Playgroud)