Fix max update depth crash on Market page
CI / build-and-push (push) Successful in 32s

The deployedModels selector used .filter() which created a new array
reference on every store change, triggering cascading re-renders.
Changed to compute bestQuality as a primitive directly in the selector.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-24 20:55:27 -04:00
parent 900d1d5190
commit d25dfe0435
+4 -5
View File
@@ -15,13 +15,12 @@ export function MarketPage() {
const tokensDemand = useGameStore((s) => s.compute.tokensPerSecondDemand);
const currentEra = useGameStore((s) => s.meta.currentEra);
const reputationScore = useGameStore((s) => s.reputation.score);
const deployedModels = useGameStore((s) => s.models.trainedModels.filter(m => m.isDeployed));
const bestQuality = useGameStore((s) => {
const deployed = s.models.trainedModels.filter(m => m.isDeployed);
return deployed.length > 0 ? Math.max(...deployed.map(m => m.benchmarkScore)) / 100 : 0;
});
const setProductPricing = useGameStore((s) => s.setProductPricing);
const setOverloadPolicy = useGameStore((s) => s.setOverloadPolicy);
const bestQuality = deployedModels.length > 0
? Math.max(...deployedModels.map(m => m.benchmarkScore)) / 100
: 0;
const eraCapBase = MARKET_SIZE_CAP[currentEra] ?? 100_000_000;
const effectiveCap = eraCapBase
* (1 + bestQuality * MARKET_CAP_QUALITY_BONUS)