PaulLeCam / react-leaflet

React components for Leaflet maps
https://react-leaflet.js.org
Other
5.13k stars 884 forks source link

Tooltip in CircleMarker fails in componentWillUnmount #211

Closed rdewit closed 8 years ago

rdewit commented 8 years ago

When using the Tooltip component within a CircleMarker, unmounting the component will with the following error:

Tooltip.js?9132:107 Uncaught TypeError: this.context.popupContainer.removeLayer is not a function

This is because of the popupContainer (i.e. the marker) may not have a 'removeLayer' method: https://github.com/PaulLeCam/react-leaflet/blob/next/src/Tooltip.js#L44

Expected behavior

No error on componentWillUnmount

Actual behavior

And 'Uncaught TypeError' on componentWillUnmount

Steps to reproduce

Create something like this:

            <CircleMarker center={markerPosition}>
              <Tooltip>
                <div>Nice tooltip!</div>
              </Tooltip>
            </CircleMarker>

Then cause a componentWillUnmount and you'll see the error in your console.

You can see it in action here: jsfiddle

PaulLeCam commented 8 years ago

Thanks for reporting this, should be fixed in beta 3.