我是新的反应,并试图从handleSubmit的firstName输入中获取值。 handleSubmit正在工作,但由于某种原因输入值未定义。我尝试了其他一些例子,但它们都是React组件中的所有表单。reactjs容器组件的表格值
let SomeForm = (props) => {
let firstName = '';
const handleSubmit = (e) => {
e.preventDefault();
console.log(firstName);
}
return (
<div>
<form onSubmit={handleSubmit}>
<TextField
floatingLabelText="First Name"
floatingLabelFixed={true}
underlineStyle={styles.underlineStyle}
underlineFocusStyle={styles.underlineFocusStyle}
value={firstName}
/>
<input type="submit" value="Submit" />
</form>
</div>
)
}
SomeForm = connect()(SomeForm)
export default SomeForm
哪里文本字段的?而且看起来你根本没有更新你的firstName – CodinCat
TextField只是来自Material UI,那你的意思是? – user1572796