You can use something like this:
handleSubmit(event) {
if (this.state.place) {
browserHistory.push(`/place_id/`+this.state.place.place_id);
} else {
event.preventDefault();
}
}
And this is the component:
<form onSubmit={ this.handleSubmit.bind(this) } ref={(c) => this.frm = c}>
<Autocomplete
onPlaceSelected={(place) => {
this.setState({place: place}, () => {this.frm.submit()});
}}
/>
</form>
The method callback setStatewill call the submitforms after , the place value has been set to state, and after that it browserHistory.pushwill be called inside handleSubmitbecause you have a place inside this.state.
source
share