diff --git a/services/web/frontend/js/features/file-tree/contexts/file-tree-path.tsx b/services/web/frontend/js/features/file-tree/contexts/file-tree-path.tsx index e0b860be87..447eec2f02 100644 --- a/services/web/frontend/js/features/file-tree/contexts/file-tree-path.tsx +++ b/services/web/frontend/js/features/file-tree/contexts/file-tree-path.tsx @@ -29,22 +29,34 @@ export const FileTreePathProvider: FC = ({ const projectId = getMeta('ol-project_id') const pathInFileTree = useCallback( - (id: string) => pathInFolder(fileTreeData, id), + (id: string) => { + if (!fileTreeData) return null + return pathInFolder(fileTreeData, id) + }, [fileTreeData] ) const findEntityByPathInFileTree = useCallback( - (path: string) => findEntityByPath(fileTreeData, path), + (path: string) => { + if (!fileTreeData) return null + return findEntityByPath(fileTreeData, path) + }, [fileTreeData] ) const previewByPathInFileTree = useCallback( - (path: string) => previewByPath(fileTreeData, projectId, path), + (path: string) => { + if (!fileTreeData) return null + return previewByPath(fileTreeData, projectId, path) + }, [fileTreeData, projectId] ) const dirnameInFileTree = useCallback( - (id: string) => dirname(fileTreeData, id), + (id: string) => { + if (!fileTreeData) return null + return dirname(fileTreeData, id) + }, [fileTreeData] )