dburles / meteor-google-maps

🗺 Meteor package for the Google Maps Javascript API v3
https://atmospherejs.com/dburles/google-maps
MIT License
196 stars 48 forks source link

componentDidUpdate not being called in route change in react-router #144

Closed cameronmcphail closed 7 years ago

cameronmcphail commented 7 years ago

Hi,

I'm having issues when navigating through pages using react-router.

I've followed the React example (very helpful) however I have had issues building it into react-router.

The first time that the page loads, here is what happens in GoogleMap.js:

  1. render
  2. componentDidMount
  3. render
  4. componentDidUpdate
  5. componentDidMount

If I switch routes (without reloading the page), then componentWillUnmount is called. So far this is all expected behaviour.

If I go back to the first page, or navigate to a new page with a GoogleMap.js component, here's what happens:

  1. render
  2. componentDidMount

There's no updating of the props, and no map is displayed. Instead, the render function will only render the string 'Loading!' (passed as a child by the parent element in the React example).

Is it possible get the map to render without refreshing the page?

dburles commented 7 years ago

@cameronmcphail yes at a glance it looks like some changes will need to be made to the GoogleMap component. Happy to accept a pull request, as I'm not sure how soon I'll have time to look at it.

dburles commented 7 years ago

@cameronmcphail fixed, https://github.com/dburles/meteor-google-maps-react-example