Skip to content

Commit bf21e85

Browse files
committed
๐Ÿ› fix: EditorNodeWrapper hooks๋ฅผ early return ์ด์ „์œผ๋กœ ์ด๋™ํ•˜์—ฌ position ์ „ํ™˜ ์‹œ React ์—๋Ÿฌ ํ•ด๊ฒฐ
1 parent 6658509 commit bf21e85

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

โ€Žpackages/ui/src/core/EditorNodeWrapper.tsxโ€Ž

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ export default function EditorNodeWrapper({
3333
const isStackItem = parentNode?.type === "Stack";
3434
const hasRelativePosition = node.style.position === "relative";
3535

36+
const { id } = node;
37+
const isSelected = selectedId === node.id;
38+
const isGroup = node.type === "Group";
39+
40+
// โ”€โ”€โ”€ ๋ชจ๋“  hooks๋Š” ์กฐ๊ฑด ๋ถ„๊ธฐ(early return) ์ „์— ํ˜ธ์ถœ โ”€โ”€โ”€
41+
const [isTransformActive, setIsTransformActive] = useState(false);
42+
const [dragPosition, setDragPosition] = useState<{
43+
x: number;
44+
y: number;
45+
}>({
46+
x: 0,
47+
y: 0,
48+
});
49+
50+
// ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋งŒ ๊ตฌ๋…
51+
const draggingId = useDragStore((s) => s.draggingNodeId);
52+
const hoveredStackId = useDragStore((s) => s.hoveredStackId);
53+
const setDraggingId = useDragStore((s) => s.setDraggingId);
54+
const setHoveredStackId = useDragStore((s) => s.setHoveredStackId);
55+
3656
// Stack ๋‚ด๋ถ€ flow ์•„์ดํ…œ์€ FlowNodeWrapper๋กœ ๋ Œ๋”๋ง
3757
const isFlowItem = isStackItem && hasRelativePosition;
3858
if (isFlowItem) {
@@ -52,35 +72,17 @@ export default function EditorNodeWrapper({
5272

5373
const isSwitchItems = isStackItem && hasRelativePosition;
5474

55-
const isSelected = selectedId === node.id;
56-
const isGroup = node.type === "Group";
5775
const wrapperStyle: React.CSSProperties = {
5876
cursor: "move",
5977
};
6078

61-
const [isTransformActive, setIsTransformActive] = useState(false);
62-
const [dragPosition, setDragPosition] = useState<{
63-
x: number;
64-
y: number;
65-
}>({
66-
x: 0,
67-
y: 0,
68-
});
69-
70-
const { id } = node;
7179
const { width, height, x, y, zIndex } = node.layout;
7280
const selectedNodeGuideClasses = {
7381
// ์‹œ๊ฐ์  ํ•ธ๋“ค์€ SelectionOverlay ํฌํƒˆ์—์„œ ๋ Œ๋”๋ง.
7482
// Rnd์˜ ํ•ธ๋“ค์€ ์ธํ„ฐ๋ž™์…˜๋งŒ ๋‹ด๋‹น (ํˆฌ๋ช…ํ•˜๊ฒŒ ์œ ์ง€)
7583
handle: "opacity-0 !w-3 !h-3 ",
7684
};
7785

78-
// ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋งŒ ๊ตฌ๋…
79-
const draggingId = useDragStore((s) => s.draggingNodeId);
80-
const hoveredStackId = useDragStore((s) => s.hoveredStackId);
81-
const setDraggingId = useDragStore((s) => s.setDraggingId);
82-
const setHoveredStackId = useDragStore((s) => s.setHoveredStackId);
83-
8486
//๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ๊ฐ€์ด๋“œ ํ‘œ์‹œ ์—ฌ๋ถ€ ๊ฒฐ์ •
8587
const isDraggingMyself = draggingId === id;
8688
const isHoveredStack = hoveredStackId === id;

0 commit comments

Comments
ย (0)