Enhancement Description
The createCustomIcon function in PriceMap.tsx creates a new SVG icon on every call without memoization, causing unnecessary re-renders.
Location
frontend/app/components/PriceMap.tsx (lines 9-25)
Current Code
const createCustomIcon = (isCheapest: boolean) => {
const color = isCheapest ? "#10b981" : "#ef4444";
const size = isCheapest ? "40px" : "32px";
const anchorY = isCheapest ? 40 : 32;
const svgIcon = `<svg ...>`;
return L.divIcon({
className: "custom-leaflet-icon bg-transparent border-none",
html: svgIcon,
// ...
});
};
Problem
- New icon created on every render
- SVG string recreated each time
L.divIcon() called repeatedly
Suggested Fix
Use useMemo or create icon instances outside the component:
const cheapestIcon = L.divIcon({ /* ... */ });
const regularIcon = L.divIcon({ /* ... */ });
// Then use conditionally
const icon = isCheapest ? cheapestIcon : regularIcon;
Impact
- Better rendering performance
- Fewer object allocations
- Smoother map interactions
Labels
enhancement, frontend, performance
Enhancement Description
The
createCustomIconfunction inPriceMap.tsxcreates a new SVG icon on every call without memoization, causing unnecessary re-renders.Location
frontend/app/components/PriceMap.tsx(lines 9-25)Current Code
Problem
L.divIcon()called repeatedlySuggested Fix
Use
useMemoor create icon instances outside the component:Impact
Labels
enhancement, frontend, performance