I have two react components: Component1 renders a Map with MapboxGl. Component2 renders a button that when clicked, makes an API call and fetches Geojson data and stores it into a variable.
Problem: Component1 needs the Geojson data to draw a route on the map. How can I pass the the data from component2 to component1? I tried with exporting the variable from component2 and importing it in component1, but it doesn't work.
Any help would be much appreciated.