Skip to content

Commit 3780524

Browse files
committed
fix: avoid unnecessary rendering of DragPreview component
1 parent ea576c8 commit 3780524

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## 1.6.1
4+
5+
_Jan 07, 2022_
6+
7+
### Fixed
8+
9+
- DragPreview component is momentarily displayed in the upper left corner of the screen after the drag operation is completed.
10+
311
## 1.6.0
412

513
_Nov 18, 2021_

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@minoru/react-dnd-treeview",
33
"description": "A draggable / droppable React-based treeview component.",
4-
"version": "1.6.0",
4+
"version": "1.6.1",
55
"license": "MIT",
66
"repository": {
77
"type": "git",

src/DragLayer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ const getItemStyles = <T extends unknown>(
3333
export const DragLayer = <T extends unknown>(): ReactElement | null => {
3434
const context = useTreeContext<T>();
3535
const monitorProps = useTreeDragLayer<T>();
36+
const { isDragging, clientOffset } = monitorProps;
3637

37-
if (!monitorProps.isDragging) {
38+
if (!isDragging || !clientOffset) {
3839
return null;
3940
}
4041

0 commit comments

Comments
 (0)