fix: app crash error (Rendered fewer hooks than expected) (#7407)

* fix:  app crash error (Rendered fewer hooks than expected)

* empty commit
This commit is contained in:
sanish chirayath
2026-03-09 19:20:39 +05:30
committed by GitHub
parent facfe325b1
commit f123a2b574

View File

@@ -483,6 +483,33 @@ const CollectionItem = ({ item, collectionUid, collectionPathname, searchText })
return items;
};
const handleCopyItem = useCallback(() => {
dispatch(copyRequest(item));
const itemType = isFolder ? 'Folder' : 'Request';
toast.success(`${itemType} copied`);
}, [dispatch, item, isFolder]);
const handlePasteItem = useCallback(() => {
// Determine target folder: if item is a folder, paste into it; otherwise paste into parent folder
let targetFolderUid = item.uid;
if (!isFolder) {
const parentFolder = findParentItemInCollection(collection, item.uid);
targetFolderUid = parentFolder ? parentFolder.uid : null;
}
dispatch(pasteItem(collectionUid, targetFolderUid))
.then(() => {
toast.success('Item pasted successfully');
})
.catch((err) => {
toast.error(err ? err.message : 'An error occurred while pasting the item');
});
}, [dispatch, collection, item, isFolder, collectionUid]);
// Update refs whenever handlers change
copyHandlerRef.current = handleCopyItem;
pasteHandlerRef.current = handlePasteItem;
const className = classnames('flex flex-col w-full', {
'is-sidebar-dragging': isSidebarDragging
});
@@ -592,33 +619,6 @@ const CollectionItem = ({ item, collectionUid, collectionPathname, searchText })
}
};
const handleCopyItem = useCallback(() => {
dispatch(copyRequest(item));
const itemType = isFolder ? 'Folder' : 'Request';
toast.success(`${itemType} copied`);
}, [dispatch, item, isFolder]);
const handlePasteItem = useCallback(() => {
// Determine target folder: if item is a folder, paste into it; otherwise paste into parent folder
let targetFolderUid = item.uid;
if (!isFolder) {
const parentFolder = findParentItemInCollection(collection, item.uid);
targetFolderUid = parentFolder ? parentFolder.uid : null;
}
dispatch(pasteItem(collectionUid, targetFolderUid))
.then(() => {
toast.success('Item pasted successfully');
})
.catch((err) => {
toast.error(err ? err.message : 'An error occurred while pasting the item');
});
}, [dispatch, collection, item, isFolder, collectionUid]);
// Update refs whenever handlers change
copyHandlerRef.current = handleCopyItem;
pasteHandlerRef.current = handlePasteItem;
// Keyboard shortcuts handler
const handleKeyDown = (e) => {
// Detect Mac by checking both metaKey and platform