I'm trying to pass the Value of my Input Form to my AppMap Component, it centers the Map on the prop city
. It works when I hardcode the state of searchValue
, but when i submit the form it does not pass the state as a prop to the AppMap Component. Does anyone know what i'm doing wrong. Thanks in advance.
class Map extends Component{
constructor(){
super()
this.state = {
value: ' ',
searchValue: "London"
};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value});
}
handleSubmit(event) {
const value = this.state.value
event.preventDefault();
this.setState ({
searchValue: value
})
}
render(){
return(
<div className='map'>
<h1>The Map</h1>
<AppMap city={this.state.searchValue} />
<Grid>
<Row className="show-grid">
<FormGroup value={this.state.value} onChange={this.handleChange} name='cardHeading' controlId="formControlsTextarea">
<Col xs={8} md={8}>
<FormControl type="text" placeholder="title" />
</Col>
<Col xs={4} md={4}>
<Button onClick={this.handleSubmit} type="submit">Submit</Button>
</Col>
</FormGroup>
</Row>
</Grid>
</div>
)
}
}
export default Map