import React, { useMemo, memo, ReactNode, useContext, CSSProperties } from 'react'; import { useDrag } from 'react-dnd'; import schema from 'components/BasicShop/schema'; import styles from './index.less'; import { dooringContext } from '@/layouts'; interface TargetBoxProps { item: any; children: ReactNode; canvasId: string; } const TargetBox = memo((props: TargetBoxProps) => { const { item } = props; const [{ isDragging }, drag] = useDrag({ item: { type: item.type, config: schema[item.type as keyof typeof schema].config, h: item.h, editableEl: schema[item.type as keyof typeof schema].editData, category: item.category, x: item.x || 0, }, collect: monitor => ({ isDragging: monitor.isDragging(), }), }); const containerStyle: CSSProperties = useMemo( () => ({ opacity: isDragging ? 0.4 : 1, cursor: 'move', height: '140px', }), [isDragging], ); return ( <>