0

I am getting geocode locations into the latt,lngg variables through axios and setState , i want to use this variables inside google-map-react package center How can i pass these state values into props .

Rest API

then(res => {
  console.log(res.data.results[0].geometry.location.lat);
  console.log(res.data.results[0].geometry.location.lng);
  // console.log(res.data[0]);

  this.setState({latt:res.data.results[0].geometry.location.lat})
  this.setState({lngg:res.data.results[0].geometry.location.lng})
})

static defaultProps = {
  center: {
    lat: 32,
    lng: 56
  },
  zoom: 5.7
};

<GoogleMapReact bootstrapURLKeys={{ key:API-KEY}} defaultCenter={this.props.center} defaultZoom={this.props.zoom}>
Marik Ishtar
  • 2,899
  • 1
  • 13
  • 27
AnotherOne
  • 78
  • 2
  • 11

1 Answers1

0

For referencing state values, you'd use this.state.center and this.state.zoom rather than this.props. which is for the props of the current component.

Zachary Haber
  • 10,376
  • 1
  • 17
  • 31