Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlay should not draw before it is added to the map #27

Open
shipstar opened this issue Mar 19, 2015 · 0 comments
Open

Overlay should not draw before it is added to the map #27

shipstar opened this issue Mar 19, 2015 · 0 comments

Comments

@shipstar
Copy link

I ran into a bug (I think) with ReactOverlayView. Here's what I think is happening:

  1. MyReactComponent renders a Map component with overlays.
  2. Before the Google Maps JS can add the overlays to the Google Map, MyReactComponent#setState triggers a re-render (because of Flux in my case).
  3. React calls ReactOverlayView#componentDidUpdate, which calls MapOverlayView#draw. (Note that MapOverlayView#add has still not been called.)
  4. MapOverlayView#getProjection returns undefined, so the following error appears: Uncaught TypeError: Cannot read property 'fromLatLngToDivPixel' of undefined

I think the fix is pretty simple -- have ReactOverlayView#componentDidUpdate check whether __node has a _containerElement before drawing (which means that onAdd has been called and drawing is 👍 ).

Pull request incoming, but feel free to push back if there's a better solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant