I'm using react-geosuggest and for some reason, the value of the Geosuggest input field doesn't get collected when I submit the form. The Geosuggest input field contains the name= in the input field same way my other input fields do yet the value always comes back empty. Any suggestions.
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>
)
}
}