diff --git a/src/components/charts/ChartsCatalogResult.client.tsx b/src/components/charts/ChartsCatalogResult.client.tsx index 103ac0214..122e78889 100644 --- a/src/components/charts/ChartsCatalogResult.client.tsx +++ b/src/components/charts/ChartsCatalogResult.client.tsx @@ -168,15 +168,12 @@ export function ChartsCatalogResult({ if (!trustedUrl) return const currentHistory = previewHistoryRef.current const currentUrl = currentHistory.entries[currentHistory.index] ?? '/' - - setPreviewHistory((current) => { - const next = updateExamplePreviewHistory(current, { - kind: message.navigationKind, - url: trustedUrl, - }) - previewHistoryRef.current = next - return next + const nextHistory = updateExamplePreviewHistory(currentHistory, { + kind: message.navigationKind, + url: trustedUrl, }) + previewHistoryRef.current = nextHistory + setPreviewHistory(nextHistory) setPreviewNavigationError('') if (message.navigationKind === 'load' || currentUrl !== trustedUrl) { setPreviewAnnotationTarget(undefined) diff --git a/src/components/charts/ChartsNotebookPage.client.tsx b/src/components/charts/ChartsNotebookPage.client.tsx index fd1e208c0..20b174204 100644 --- a/src/components/charts/ChartsNotebookPage.client.tsx +++ b/src/components/charts/ChartsNotebookPage.client.tsx @@ -808,15 +808,12 @@ export function ChartsNotebookPage() { if (!trustedUrl) return const currentHistory = previewHistoryRef.current const currentUrl = currentHistory.entries[currentHistory.index] ?? '/' - - setPreviewHistory((current) => { - const next = updateExamplePreviewHistory(current, { - kind: message.navigationKind, - url: trustedUrl, - }) - previewHistoryRef.current = next - return next + const nextHistory = updateExamplePreviewHistory(currentHistory, { + kind: message.navigationKind, + url: trustedUrl, }) + previewHistoryRef.current = nextHistory + setPreviewHistory(nextHistory) setPreviewNavigationError('') if (message.navigationKind === 'load' || currentUrl !== trustedUrl) { setPreviewAnnotationTarget(undefined)