I'm trying to display react component based on what the pair name is, but I am not sure how to get that to happen. This is the code I have so far, any suggestions?
class App extends React.Component {
state = {
bases: ['EUR', 'AUD', 'CAD', 'JPY', 'NZD'],
selectedBase: 'USD',
};
displayGraph = () => {
if(document.getElementById('pairName').innerText === 'USD/EUR'){
<Graph defaultBase={"EUR"} />
} else if (document.getElementById('pairName').innerText === 'USD/CAD'){
<Graph defaultBase={"CAD"} />
} else if(document.getElementById('pairName').innerText === 'USD/AUD'){
<Graph defaultBase={"NZD"}/>
} else if(document.getElementById('pairName').innerText === 'USD/NZD'){
<Graph defaultBase={"AUD"}/>
} else if (document.getElementById('pairName').innerText === 'USD/JPY') {
<Graph defaultBase={"JPY"}/>
}
}
render(){
return (
<div id="three">
<h2 id="pairName">USD/EUR</h2>
{/* GOAL: show graphs when correct pairs are selected */}
{this.displayGraph}
</div>
}
}
export default App;
{ "USD/EUR": { ... } }.