fix: remove useCallback, fixing null socket issue when reading files

This commit is contained in:
James Murdza 2024-09-01 21:53:59 -07:00
parent 665e36603f
commit 9fd1f81654

View File

@ -491,14 +491,13 @@ export default function CodeEditor({
const fileCache = useRef(new Map());
// Debounced function to get file content
const debouncedGetFile = useCallback(
debounce((tabId, callback) => {
const debouncedGetFile =
(tabId: any, callback: any) => {
socket?.emit('getFile', tabId, callback);
}, 300), // 300ms debounce delay, adjust as needed
[]
);
} // 300ms debounce delay, adjust as needed
const selectFile = (tab: TTab) => {
const selectFile = useCallback((tab: TTab) => {
if (tab.id === activeFileId) return;
setGenerate((prev) => ({ ...prev, show: false }));
@ -523,7 +522,7 @@ export default function CodeEditor({
setEditorLanguage(processFileType(tab.name));
setActiveFileId(tab.id);
}, [activeFileId, tabs, debouncedGetFile]);
};
// Close tab and remove from tabs
const closeTab = (id: string) => {