diff --git a/src/components/App.tsx b/src/components/App.tsx
index 286371e4..6c83d572 100644
--- a/src/components/App.tsx
+++ b/src/components/App.tsx
@@ -1,3 +1,5 @@
+import { useMemo } from 'react'
+import { Config, ConfigProvider } from '../hooks/useConfig.js'
import { getHttpSource } from '../lib/sources/httpSource.js'
import { getHyperparamSource } from '../lib/sources/hyperparamSource.js'
import Page from './Page.js'
@@ -10,20 +12,20 @@ export default function App() {
const source = getHttpSource(sourceId) ?? getHyperparamSource(sourceId, { endpoint: location.origin })
+ // Memoize the config to avoid creating a new object on each render
+ const config: Config = useMemo(() => ({
+ routes: {
+ getSourceRouteUrl: ({ sourceId }) => `/files?key=${sourceId}`,
+ getCellRouteUrl: ({ sourceId, col, row }) => `/files?key=${sourceId}&col=${col}&row=${row}`,
+ },
+ }), [])
+
if (!source) {
return
Could not load a data source. You have to pass a valid source in the url.
}
return (
- `/files?key=${sourceId}`,
- getCellRouteUrl: ({ sourceId, col, row }) => `/files?key=${sourceId}&col=${col}&row=${row}`,
- },
- }}
- />
+
+
+
)
}
diff --git a/src/components/Breadcrumb.tsx b/src/components/Breadcrumb.tsx
index 4702c7c0..9f264788 100644
--- a/src/components/Breadcrumb.tsx
+++ b/src/components/Breadcrumb.tsx
@@ -1,22 +1,22 @@
import type { ReactNode } from 'react'
-import type { RoutesConfig } from '../lib/routes.js'
+import { useConfig } from '../hooks/useConfig.js'
import type { Source } from '../lib/sources/types.js'
-export type BreadcrumbConfig = RoutesConfig
interface BreadcrumbProps {
source: Source,
- config?: BreadcrumbConfig
children?: ReactNode
}
/**
* Breadcrumb navigation
*/
-export default function Breadcrumb({ source, config, children }: BreadcrumbProps) {
+export default function Breadcrumb({ source, children }: BreadcrumbProps) {
+ const { routes } = useConfig()
+
return