perf(DndContext): ignore some context when UI is not designable

This commit is contained in:
Zeke Zhang 2024-10-25 22:15:25 +08:00
parent a7e086ccad
commit e1e8f54d03

View File

@ -77,6 +77,7 @@ const useDragEnd = (onDragEnd) => {
export type DndContextProps = Props;
export const DndContext = (props: Props) => {
const { designable } = useDesignable();
const { t } = useTranslation();
const [visible, setVisible] = useState(true);
@ -94,6 +95,10 @@ export const DndContext = (props: Props) => {
const onDragEnd = useDragEnd(props?.onDragEnd);
if (!designable) {
return <>{props.children}</>;
}
return (
<DndKitContext collisionDetection={rectIntersection} {...props} onDragStart={onDragStart} onDragEnd={onDragEnd}>
<DragOverlay