我正在使用react-geosuggest
,出于某种原因,Geosuggest
当我提交表单时,输入字段的值不会被收集。该Geosuggest
输入字段包含name=
在输入字段的方式我的其他输入字段做但value总是空空的回来一样。有什么建议。
export default class ContactDetails extends React.Component {
constructor(props) {
super(props);
this.state = {
'name.first': '',
'address.fullAddress': '',
};
this.handleInputChange = this.handleInputChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleInputChange(event) {
const target = event.target;
const value = target.type === 'checkbox' ? target.checked : target.value;
const name = target.name;
this.setState({
[name]: value
});
}
handleSubmit(event) {
event.preventDefault();
var data = {
'name.first': this.state['name.first'],
'address.fullAddress': this.state['address.fullAddress'],
};
console.log("data: ", data);
}
render() {
return (
<form onSubmit={this.handleSubmit} noValidate>
<Geosuggest
name="address.fullAddress"
placeholder="Full address"
value={this.state['address.fullAddress']}
onChange={this.handleInputChange}
initialValue={this.state['address.fullAddress']}
location={new google.maps.LatLng(25.2744, 133.7751)}
radius="0"
/>
<input
name="name.first"
type="text"
value={this.state['name.first']}
onChange={this.handleInputChange}
className={this.state.errors['name.first'] ? "validate invalid" : "validate" }
/>
<button className="btn waves-effect waves-light" type="submit" name="action">
Save
</button>
</form>
)
}
}