Skip to content

Commit

Permalink
🔨 do not use key as a react prop (#3783)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann authored Jul 10, 2024
1 parent df78d6c commit 6d389fc
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ export class DiscreteBarChart
opacity={GRAPHER_AREA_OPACITY_DEFAULT}
style={{ transition: "height 200ms ease" }}
/>
<Halo key={series.seriesName + "-label"}>
<Halo id={series.seriesName + "-label"}>
<text
x={0}
y={0}
Expand Down
4 changes: 2 additions & 2 deletions packages/@ourworldindata/grapher/src/halo/Halo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ const defaultHaloStyle: React.CSSProperties = {
}

export function Halo(props: {
key: React.Key
id: React.Key
children: React.ReactElement
style?: React.CSSProperties
}): React.ReactElement {
const halo = React.cloneElement(props.children, {
style: { ...defaultHaloStyle, ...props.style },
})
return (
<React.Fragment key={props.key}>
<React.Fragment key={props.id}>
{halo}
{props.children}
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class NoDataModal extends React.Component<{
<g className="no-data">
<rect {...bounds.toProps()} fill="#fff" opacity={0.6} />

<Halo key="no-data-message">
<Halo id="no-data-message">
<text
x={center.x}
y={center.y}
Expand All @@ -88,7 +88,7 @@ export class NoDataModal extends React.Component<{
</Halo>

{showHelpText && (
<Halo key="no-data-help">
<Halo id="no-data-help">
<text
x={center.x}
y={center.y + padding / 2}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class ComparisonLine extends React.Component<{
}}
clipPath={`url(#axisBounds-${renderUid})`}
>
<Halo key={`path-${renderUid}`}>
<Halo id={`path-${renderUid}`}>
<textPath
baselineShift="-0.2rem"
href={`#path-${renderUid}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ export class ScatterPointsWithLabels extends React.Component<ScatterPointsWithLa
return series.allLabels
.filter((label) => !label.isHidden)
.map((label) => (
<Halo key={series.displayKey + "-endLabel"}>
<Halo
key={series.displayKey + "-endLabel"}
id={series.displayKey + "-endLabel"}
>
<text
id={makeIdForHumanConsumption(
"scatter-label",
Expand Down Expand Up @@ -555,7 +558,10 @@ export class ScatterPointsWithLabels extends React.Component<ScatterPointsWithLa
return series.allLabels
.filter((label) => !label.isHidden)
.map((label, index) => (
<Halo key={`${series.displayKey}-label-${index}`}>
<Halo
key={`${series.displayKey}-label-${index}`}
id={`${series.displayKey}-label-${index}`}
>
<text
id={makeIdForHumanConsumption(
"scatter-label",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ const LegendItem = ({
strokeWidth={circleStrokeWidth}
opacity={circleOpacity}
/>
<Halo key={label} style={{ ...style, strokeWidth: 3.5 }}>
<Halo id={label} style={{ ...style, strokeWidth: 3.5 }}>
<text
x={cx}
y={cy - circleRadius}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ export class StackedDiscreteBarChart
/>
))}
{this.showTotalValueLabel && (
<Halo key={entityName + "-value-label"}>
<Halo id={entityName + "-value-label"}>
<text
id={makeIdForHumanConsumption(
"total",
Expand Down

0 comments on commit 6d389fc

Please sign in to comment.