We got how to prevent drag drop image with jquery with $('img').on('dragstart', function(event) { event.preventDefault(); });
but I want to achieve the same in a react app, and without jquery. How can I do this ? a) locally (image per image) b) globally (for all images of the react app)
I still want to keep control over other interactions, so img { pointer-events: none; }
is not a solution.
The goal is to prevent saving image through drag and drop.
You can use onDragStart
:
onDragStart={this.preventDragHandler}
And the handler:
preventDragHandler = (e) => {
e.preventDefault();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With