alex3165 / react-leaflet-draw

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

Adding/Removing EditControl Does not update Callbacks correctly #14

Closed AndrewLipscomb closed 7 years ago

AndrewLipscomb commented 7 years ago

Got the bug to work with a minimal example Use this file instead of editcontrol.js on the minimal example in the repo https://gist.github.com/ALTinners/6a15e4f1ad2653ee23d1d15132f46a8f

To replicate:

  1. Start app and press Toggle Edit button. Controls should be enabled, and drawing works as normal.
  2. Toggle Edit twice so that the Edit Controls are deleted and created again. Draw anything, and the create function will be triggered twice.
  3. Toggling each time adds another extra trigger for the function, so I'm guessing that the bindings for draw:create (and possibly other signals) are not being destroyed properly when the React component is destroyed.

I can't see any code in the react-leaflet-draw source that relates to React component destructors; my understanding was that this was abstracted by React (or possibly by react-leaflet).

alex3165 commented 7 years ago

Hey @ALTinners thanks for the issue , can you try with react-leaflet-draw@0.13.0 ?