Skip to content

Commit

Permalink
Chore: Remove a few instances of "no array index key" eslint comment (#…
Browse files Browse the repository at this point in the history
…3997)

## Description
- [x] use values in keys in-place-of indexes in `polar/Pie` and
`cartesian/Bar` components

## Related Issue
[3273](#3273)

## Motivation and Context
- contribute to the repo

## How Has This Been Tested?
- [x] all existing unit tests pass (_no new `duplicate key` errors are
present as a result_)

## Types of changes
- [x] Technical Cleanup 

## Checklist:
- [x] My code follows the code style of this project.
- [x] All new and existing tests passed.
  • Loading branch information
imagineLife committed Nov 27, 2023
1 parent 68192fe commit 91a7e39
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/cartesian/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export class Bar extends PureComponent<Props, State> {
<Layer
className="recharts-bar-rectangle"
{...adaptEventsOfChild(this.props, entry, i)}
key={`rectangle-${i}`} // eslint-disable-line react/no-array-index-key
key={`rectangle-${entry?.x}-${entry?.y}-${entry?.value}`}
>
<BarRectangle {...props} />
</Layer>
Expand Down Expand Up @@ -450,9 +450,9 @@ export class Bar extends PureComponent<Props, State> {

return (
<Layer {...errorBarProps}>
{errorBarItems.map((item: ReactElement<ErrorBarProps>, i: number) =>
{errorBarItems.map((item: ReactElement<ErrorBarProps>) =>
React.cloneElement(item, {
key: `error-bar-${i}`, // eslint-disable-line react/no-array-index-key
key: `error-bar-${clipPathId}-${item.props.dataKey}`,
data,
xAxis,
yAxis,
Expand Down
5 changes: 2 additions & 3 deletions src/polar/Pie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,7 @@ export class Pie extends PureComponent<Props, State> {
}

return (
// eslint-disable-next-line react/no-array-index-key
<Layer key={`label-${i}`}>
<Layer key={`label-${entry.startAngle}-${entry.endAngle}`}>
{labelLine && Pie.renderLabelLineItem(labelLine, lineProps)}
{Pie.renderLabelItem(label, labelProps, getValueByDataKey(entry, realDataKey))}
</Layer>
Expand Down Expand Up @@ -498,7 +497,7 @@ export class Pie extends PureComponent<Props, State> {
tabIndex={-1}
className="recharts-pie-sector"
{...adaptEventsOfChild(this.props, entry, i)}
key={`sector-${i}`} // eslint-disable-line react/no-array-index-key
key={`sector-${entry?.startAngle}=${entry?.endAngle}`}
>
<Shape option={sectorOptions} isActive={isActive} shapeType="sector" {...sectorProps} />
</Layer>
Expand Down

0 comments on commit 91a7e39

Please sign in to comment.