diff --git a/packages/dashboard/src/components/dashboard/index.tsx b/packages/dashboard/src/components/dashboard/index.tsx index 90685a694..d5b6a133b 100644 --- a/packages/dashboard/src/components/dashboard/index.tsx +++ b/packages/dashboard/src/components/dashboard/index.tsx @@ -1,4 +1,4 @@ -import React, { memo } from 'react'; +import React, { memo, useMemo } from 'react'; import { Provider } from 'react-redux'; import { DndProvider } from 'react-dnd'; import { TouchBackend } from 'react-dnd-touch-backend'; @@ -64,23 +64,34 @@ const Dashboard: React.FC = ({ ? debounce(onViewportChange, 100) : undefined; - const readOnly = initialViewMode && initialViewMode === 'preview'; + const readOnly = useMemo(() => { + return initialViewMode && initialViewMode === 'preview'; + }, [initialViewMode]); + + const initialStore = useMemo(() => { + return configureDashboardStore({ + ...toDashboardState(dashboardConfiguration), + readOnly, + isEdgeModeEnabled: isEdgeModeEnabled(edgeMode), + }); + }, [dashboardConfiguration, edgeMode, readOnly]); + + const clients = useMemo( + () => getClients(clientConfiguration), + [clientConfiguration] + ); + const queries = useMemo( + () => getQueries(clientConfiguration, edgeMode), + [clientConfiguration, edgeMode] + ); return ( <> {showFPSMonitor && } - - + + - +