react-leaflet-draw
react-leaflet-draw copied to clipboard
Edit toolbar don't disable dynamically
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
I've got the same problem here, the component should update to any change of the props
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