i am using google maps react.
I am trying to fetch data on latitude and longitude from my APIinto the Google Maps as markers.
Getting an error "TypeError: markers.map is not a function"
here is code snippet -
const [markers,setmarkers] = useState([]);
const GetCoordinates = (info) => {
setmarkers(info);}
function GetMaps(props){
const AnyComponent = ({text}) => <div>{text}</div>
defaultmarkers = {center:{lat: xxxx, lng: xxxx}, zoom: 10}
}
return (<div style={{height:'100vh', width:'100vw' }}>
<GoogleMapReact
bootstrapURLKeys = xxxxxx
defaultcenter= {defaultmarkers.center}
defaultZoom= {defaultmarkers.zoom}>
<AnyComponent>
<ul>
{markers.map(x => ( //////getting error on this line
<li key={x.id}>
lat={x.lat} // pull from API data
lng={x.lng} // pull info from API
text={x.title}
</li>))}</ul>
</AnyComponent><GoogleMapReact>
<GetMaps /> // function called in return tag
Getting an error "TypeError: markers.map is not a function"