import React, { useEffect } from "react";

const PageDragPreventDefault = () => {
  const preventDefaults = (e) => {
    e.preventDefault();
    e.stopPropagation();
  };

  useEffect(() => {
    const dragEvents = ["dragenter", "dragover", "dragleave", "drop"];
    dragEvents.forEach((eventName) => {
      document.body.addEventListener(eventName, preventDefaults, false);
    });
    return () => {
      dragEvents.forEach((eventName) => {
        document.body.removeEventListener(eventName, preventDefaults, false);
      });
    };
  }, []);

  return <></>;
};

export default PageDragPreventDefault;
