alex3165 / react-leaflet-draw

React component for leaflet-draw on top of react-leaflet
228 stars 152 forks source link

Map props not found for componentWillMount #4

Closed AndrewLipscomb closed 8 years ago

AndrewLipscomb commented 8 years ago

Hey mate, been having a play with this package in a Meteor app. I'm currently hitting a bug where props.map is undefined when componentWillMount is triggered.

Meteor 1.3 with react-leaflet as a base, so it may be beyond the scope of what you're looking at. I was going to have a play around (see if pushing the map.on(...) functions back to componentDidMount makes a difference) but I can't seem to find a way to rebuild the package....got a gulp/grunt file you use?

Cheers, Tinners

tigleym commented 8 years ago

As of react-leaflet@0.12.0, I know some breaking changes were implemented where Leaflet instances were moved from props to context. You might have to rollback your version of react-leaflet to 0.11.7 for react-leaflet-draw to work.

https://github.com/PaulLeCam/react-leaflet/releases

AndrewLipscomb commented 8 years ago

Yeah, that looks to be it; cheers @TigleyM

I'll clone the repo and see if I can get the minimal example to work with react-leaflet@0.12.0, will update here if I get anywhere

tigleym commented 8 years ago

Forked the repo and had to changeEditControl extends MapControl to EditControl extends LayersControl , since layerContainer is no longer accessible via props and LayersControl provides the layerContainer context to its children.

alex3165 commented 8 years ago

Good job ! thank you for the PR @TigleyM !

gpbmike commented 8 years ago

I think this was fixed by #5 and #6. Thanks!