react-leaflet-draw icon indicating copy to clipboard operation
react-leaflet-draw copied to clipboard

Edit toolbar don't disable dynamically

Open tkhametov opened this issue 5 years ago • 2 comments

I have an issue when I want to disable edit toolbar dynamically. See part of render() method below:

<FeatureGroup ref={this.saveLayerContainer}>
   <EditControl
      draw={{
         marker: false,
         rectangle: false,
         polyline: false,
      }}
      edit={{ edit: isEditable, remove: false }}
   />
   <CustomMapElement
       values={this.calculateValaues}
   />
</FeatureGroup>

I calculate value of isEditable in render() method. But it does not work because EditControl is not updated when draw props is not updated. However, if I will update draw component together with edit it will work.

I think you should add checking for edit value in componentDidUpdate too. https://github.com/alex3165/react-leaflet-draw/blob/05730b53a09296cfa6d4bc5fe65970bf8308f1d2/src/EditControl.js#L104-L106

tkhametov avatar Oct 23 '19 13:10 tkhametov

I've got the same problem here, the component should update to any change of the props

niddu85 avatar Jul 09 '20 07:07 niddu85

I've got the same problem here, the component should update to any change of the props

As a workaround, you could update edit with draw property, as far as I remember it helped me one year ago

tkhametov avatar Jul 14 '20 12:07 tkhametov