question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GoogleMap: defaultCenter prop changed. You can't change default props.

See original GitHub issue

I used the map component like this:

<GoogleMap
            bootstrapURLKeys={{
              key:GoogleMapsApiKey,
              language:'en'
            }}
            defaultCenter={{lat:4.352130,lng:50.845926}}
            center={{lat: this.state.office.latitude, lng: this.state.office.longitude}}
            defaultZoom={9}
            zoom={12}
          >
          </GoogleMap>

So why is it complaining that I changed the defaultCenter prop?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

24reactions
lokesh755commented, May 25, 2017

I would suggest to use “center” instead of “defaultCenter”. That works because it doesn’t compare with older center.

0reactions
lock[bot]commented, Dec 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Child component won't update with new props after setState
The error says exactly what's wrong, you can't change the defaults. Set defaultCenter once, then use your dynamic state variable on center ....
Read more >
A Beginner's Guide to google-map-react | by Matt Croak Code
First, you should set up some defaultProps for your map component to use. This is not only useful to implement as your map...
Read more >
React Google Maps Style Guide
react-google-maps provides a set of React components wrapping the underlying Google Maps JavaScript API v3 instances. The wrapping simply do: props delegation ...
Read more >
google-map-react | Yarn - Package Manager
google-map -react is a component written over a small set of the Google Maps API. It allows you to render any React component...
Read more >
google-map-react - npm
It allows you to render any React component on the Google Map. ... export default function SimpleMap(){ const defaultProps = { center: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found