Is there a way to trigger an event when you backspace and delete an image using slate.js?

570 views Asked by At

I am using slate.js and when I delete an image by pressing backspace the image is removed from state and no longer exists. However, with the image still being stored on the server. I would like to trigger an event to delete the image from the server.

I have my image element below where I have got the image id. I want an event to be triggered on delete so I can use that id to delete the image from the backend.

export const ImageElement = ({ attributes, element }) => {

  return (
      <img
id='imageid'
        className="rounded "
        alt="uploaded image"
        src={element.url}
      />
    
  )
}
1

There are 1 answers

1
coder5666666666 On

In slate.js for any element that gets removed from the state. You can use component unmounts in react on the component and trigger any deletion events from there.