Reputation: 63
I have a file called map.js which has the map and markers
{Towers.TowerList.map((tower) => (
<Marker key={tower.id}
position={tower.coords}
onClick={() => {
Drawgraph(tower); //Doubtful
setTower(tower)
}
} />
The setTower()
comes from a React hook.
I want to plot a chartjs graph when a particular marker is clicked. But chart is to be made in D.js
, while the information for clicked graph is in this one. I wanted so that Drawgraph() could determeine which dataset to use, make a chart and take the chart to D.js
(where chart is to be displayed). This is what D.js
looks like :
//somewhere in D.js
<div className="chart-wrapper">
<DrawGraph /> //Doubtful
</div>
How to go about this situation?
Upvotes: 1
Views: 107
Reputation: 2602
In react you can use props to pass data from one component to its child component.
If the <DrawGraph />
Is not a child component, you can use state management libraries like redux
or the built-in Context API.
Upvotes: 1