I'm trying to show the data that comes from a promise getTiendas in the const that defines the GoogleMaps markers but I'm not making it, what is wrong?
import React from 'react';
import AppBar from 'material-ui/AppBar';
import IconButton from 'material-ui/IconButton';
import NavigationClose from 'material-ui/svg-icons/navigation/close';
import NavBar from '../../components/NavBar';
import { withScriptjs, withGoogleMap, GoogleMap, Marker, InfoWindow, } from "react-google-maps"
const { compose, withProps, withStateHandlers } = require("recompose");
import { API_ROOT } from '../../config/api-config';
let getTiendas = new Promise((resolve, reject) => {
fetch('${API_ROOT}/map/')
.then(result => result.json())
.then(res => {
if (res.success) {
resolve(res.data);
}else{
reject('Ha ocurrido un problema, intenta mas tarde.');
}
});
});
const MyMapComponent = compose(
withStateHandlers(() => ({
isOpen: false,
}), {
onToggleOpen: ({ isOpen }) => () => ({
isOpen: !isOpen,
})
}),
withScriptjs,
withGoogleMap
)(props =>
<GoogleMap
defaultZoom={4}
defaultCenter={{ lat: 19.432608, lng: -99.133209 }}
>
{getTiendas.then((data) => {
<Marker
position={{ lat: 20.666667, lng: -103.333333 }}
onClick={props.onToggleOpen}
>
{props.isOpen && <InfoWindow onCloseClick={props.onToggleOpen}>
<span></span>
</InfoWindow>}
</Marker>
})}
</GoogleMap>
);