With React, render and populate new select upon onChange from the first.
I have successfully fetched the data upon onChange from the first select dropdown. Now how to get the updated state rendered on the same page.
constructor(props){
super(props);
this.state = {
partitions: []
}
handleSubmit(event) {
const pk = event.target.value;
fetch(`api/locations/${pk}`)
.then(response => response.json())
.then(body => this.setState({partitions: body}))
}
render() {
return (
<div>
<div className={"form-group"}>
<label>Locations</label>
<select className={"form-control"}
name={"location"} value={"location"}
onChange={this.handleSubmit}>
<option value={""} key={""}>---------</option>
{Object.entries(this.props.data)
.map(location=>
<option value={location[1].id}
key={key(location)}>
{location[1].location}
</option>
)}
</select>
</div>
How do I get that data to render underneath the first select dropdown?