ошибка перекомпоновки react-google-maps - `не функция`

Я получаю сообщение об ошибке при попытке запустить определенный компонент react-google-maps верхнего уровня. (0 , _reactGoogleMaps.withProps) is not a function

Вот мой код (codesandbox):

import * as React from 'react'
import {
  withScriptjs,
  withGoogleMap,
  GoogleMap,
  Marker,
  withProps,
  withState,
  withHandlers
} from "react-google-maps";
import { compose } from 'recompose'

var service, refs;
const LocationPicker = compose(
  withProps({
    googleMapURL: "https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,places&key=AIzaSyDnKwHUG_EJXN5EEW6hTftZHYo8E8QTTXY",
    loadingElement: <div style={{ height: `100%` }} />,
    containerElement: <div style={{ height: `400px` }} />,
    mapElement: <div style={{ height: `100%` }} />,
  }),
  withScriptjs,
  withGoogleMap,
  withState('places', '', ''),
  withHandlers(() => {
    refs = {
      map: undefined,
    }

    return {
      onMapMounted: () => ref => {
        refs.map = ref
        service = new google.maps.places.PlacesService(refs.map.context.__SECRET_MAP_DO_NOT_USE_OR_YOU_WILL_BE_FIRED);
      },
    }
  }),
)((props) => {
  return (
    <GoogleMap
      ref={props.onMapMounted}
      defaultZoom={13}
      defaultCenter={{ lat: 42.3570637, lng: -71.06257679999999 }}
    >
      {props.marker &&
        <Marker position={{ lat: props.marker.lat, lng: props.marker.lng }} draggable={true} />
      }
    </GoogleMap>
  )
})



class HomeMap extends Component {
  state = {
    sideBarOpen: true,
    values: [800, 1200]
  }

  render() {
    return (
      <div>
        <div id="map-wrapper">
          <LocationPicker
            googleMapURL="https://maps.googleapis.com/maps/api/js?key=AIzaSyC4R6AN7SmujjPUIGKdyao2Kqitzr1kiRg&v=3.exp&libraries=geometry,drawing,places"
            loadingElement={<div style={{ height: `100%` }} />}
            containerElement={<div style={{ height: `400px` }} />}
            mapElement={<div style={{ height: `100%` }} />}
            lat={42.357527}
            lng={-71.062778}
            marker={this.state.marker}
          />
        </div>
      </div>)
  }
}

Любые идеи?


person SomethingsGottaGive    schedule 08.07.2018    source источник


Ответы (1)


Вы импортируете withProps из react-google-maps. Вы должны импортировать его из recompose:

import { compose, withProps } from 'recompose';
person Tholle    schedule 08.07.2018