import * as React from "react"; import { WidgetProps } from "../widgets/BaseWidget"; import { useDrag, DragPreviewImage, DragSourceMonitor } from "react-dnd"; import blankImage from "../assets/images/blank.png"; import { ContainerProps } from "./ContainerComponent"; type DraggableComponentProps = WidgetProps & ContainerProps; const DraggableComponent = (props: DraggableComponentProps) => { const [{ isDragging }, drag, preview] = useDrag({ item: props, collect: (monitor: DragSourceMonitor) => ({ isDragging: monitor.isDragging(), }), }); return (
{props.children}
); }; // class DraggableComponent extends React.Component { // render() { // return props.connectDragSource( // , // ); // } // } // const widgetSource = { // beginDrag(props: WidgetProps) { // return { // widgetId: props.widgetId, // widgetType: props.type, // }; // }, // }; const widgetType = (props: WidgetProps) => { return props.type; }; // function collect(connect: DragSourceConnector, monitor: DragSourceMonitor) { // return { // connectDragSource: connect.dragSource(), // isDragging: monitor.isDragging(), // }; // } // export default DragSource(widgetType, widgetSource, collect)( // DraggableComponent, // ); export default DraggableComponent;