Fix dashboard and map tab lag with memoization and code splitting
Memoize createMap() in DottedMap (was regenerating 8000 SVG dots every render) and convert 11 heavy dashboard components to next/dynamic imports so the page shell renders instantly instead of blocking on one massive render pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,10 @@ export default function DottedMap({ data, className }: DottedMapProps) {
|
||||
const dotRadius = 0.25
|
||||
const [tooltip, setTooltip] = useState<{ x: number; y: number; country: string; pageviews: number } | null>(null)
|
||||
|
||||
const { points, addMarkers } = createMap({ width, height, mapSamples: 8000 })
|
||||
const { points, addMarkers } = useMemo(
|
||||
() => createMap({ width, height, mapSamples: 8000 }),
|
||||
[width, height],
|
||||
)
|
||||
|
||||
const markerData = useMemo(() => {
|
||||
if (!data.length) return []
|
||||
@@ -48,7 +51,7 @@ export default function DottedMap({ data, className }: DottedMapProps) {
|
||||
() => markerData.map((d) => ({ lat: d.lat, lng: d.lng, size: d.size })),
|
||||
[markerData],
|
||||
)
|
||||
const processedMarkers = addMarkers(markerInputs)
|
||||
const processedMarkers = useMemo(() => addMarkers(markerInputs), [addMarkers, markerInputs])
|
||||
|
||||
// Compute stagger helpers
|
||||
const { xStep, yToRowIndex } = useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user