Fix JS syntax error in ObservedRateDensity.jsx — const declarations were embedded inside JSX
Deploy to git-pages / deploy (push) Successful in 11s

The obsWidth, lowerX, upperWidth, and medX variables were declared inline within the SVG <g> element's children, which is invalid JavaScript/JSX. This caused 'ReferenceError: obsWidth is not defined' at runtime when rendering Chart 5.

Fix: Moved all const declarations to the top of the map callback, before the return statement.
This commit is contained in:
2026-08-10 12:21:00 -04:00
parent 116730b685
commit dd69bb6f8f
+5 -4
View File
@@ -75,6 +75,11 @@ export default function ObservedRateDensity({ quadData }) {
{modelResults.map((r, i) => {
const rowY = margin.top + i * (height / modelResults.length + 8)
const barHeight = height / modelResults.length - 6
// Pre-compute coordinates outside JSX to avoid embedding statements in render output
const obsWidth = (r.observedRate / maxRate) * (width - margin.left - margin.right)
const lowerX = margin.left + (r.modeledLower / maxRate) * (width - margin.left - margin.right)
const upperWidth = ((r.modeledUpper - r.modeledLower) / maxRate) * (width - margin.left - margin.right)
const medX = margin.left + (r.modeledRateMedian / maxRate) * (width - margin.left - margin.right)
return (
<g key={r.modelId}>
@@ -82,16 +87,12 @@ export default function ObservedRateDensity({ quadData }) {
<rect x={margin.left} y={rowY} width={width - margin.left - margin.right} height={barHeight} rx={3} fill="var(--cv-paper-2)" />
{/* Observed rate bar (solid) */}
const obsWidth = (r.observedRate / maxRate) * (width - margin.left - margin.right)
<rect x={margin.left} y={rowY + 4} width={obsWidth} height={barHeight - 8} fill="var(--cv-navy-600)" rx={2} opacity={0.9} />
{/* Model interval (dashed outline showing 95% range) */}
const lowerX = margin.left + (r.modeledLower / maxRate) * (width - margin.left - margin.right)
const upperWidth = ((r.modeledUpper - r.modeledLower) / maxRate) * (width - margin.left - margin.right)
<rect x={lowerX} y={rowY + 4} width={upperWidth} height={barHeight - 8} fill="none" stroke="var(--teal-600)" strokeWidth={1.5} rx={2} />
{/* Model median marker */}
const medX = margin.left + (r.modeledRateMedian / maxRate) * (width - margin.left - margin.right)
<line x1={medX} y1={rowY + 3} x2={medX} y2={rowY + barHeight - 3} stroke="var(--teal-600)" strokeWidth={2} />
{/* Observed rate label */}