Hi folks,
It’s been a while since I last asked for help and I am really stuck on something here.
Basically I have a react app, that calls for data and maps over the data. Then I have a dropdown that gives the user values but when they click the dropdown and on componentDidMount there is not data from the .map
Here is a code sandbox:
Here is my code:
import React, { Component } from 'react'
export class Results extends Component {
constructor(){
super()
this.state = {
data: []
}
this.handleChangeCourse = this.handleChangeCourse.bind(this);
}
componentDidMount(){
const data = require("../fakeOpps.json");
this.setState({ data: data });
console.log("data comp did mount below:");
console.log(data);
}
handleChangeCourse = event => {
this.setState({ Opportunity: event.target.value });
};
//Get the data for opportunies
getUnique(arr, comp) {
const unique = arr
//store the comparison values in array
.map(e => e[comp])
// store the keys of the unique objects
.map((e, i, final) => final.indexOf(e) === i && i)
// eliminate the dead keys & store unique objects
.filter(e => arr[e])
.map(e => arr[e]);
return unique;
}
render() {
const Opportunity = this.getUnique(this.state.data, "Opportunity");
console.log(" opp below:");
console.log(Opportunity);
const data = this.state.data;
const filterDropdown = data.filter(function (result) {
return result.Opportunity === data;
});
console.log('fil');
console.log(filterDropdown);
return (
<div>
<label>
Looping through Courses tag from Json File
<select
value={this.state.data}
onChange={this.handleChangeCourse}
>
{Opportunity.map(data => (
<option key={data.Id} value={data.Opportunity}>
{data.Opportunity}
</option>
))}
</select>
</label>
<div>
<h1>Looped Data Here</h1>
{filterDropdown.map(data => (
<div key={data.Id} style={{ margin: "10px" }}>
{data.Opportunity}
<br />
</div>
))}
</div>
</div>
)
}
}
export default Results
Where am I going wrong here?! I’m so lost - cheers 
John.