Skip to content

Commit

Permalink
fix(radio-group, checkbox-group): add index to option keys
Browse files Browse the repository at this point in the history
  • Loading branch information
EkaterinaMozheiko authored and apust committed Dec 24, 2020
1 parent 66d4d56 commit 3b8f517
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
'import/prefer-default-export': 'off',
'react/require-default-props': 'off',
'typescript-sort-keys/interface': 'error',
'react/no-array-index-key': 'off'
},
settings: {
react: {
Expand Down
4 changes: 2 additions & 2 deletions src/packages/core/src/checkbox-group/CheckboxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export const CheckboxGroup = (props: CheckboxGroupProps) => {
}
};

const renderOptions = options.map((option) => (
const renderOptions = options.map((option, index) => (
<Checkbox
key={option.value}
key={`${option.value}-${index}`}
label={option.title}
description={option.description}
checked={value.includes(option.value)}
Expand Down
3 changes: 1 addition & 2 deletions src/packages/core/src/datalist/DataList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export function DataList(props: DataListProps) {
return (
<div
className={lineClassNames}
/* eslint-disable-next-line react/no-array-index-key */
key={`${index}-${item.title}`}
key={`${item.title}-${index}`}
>
<div className="_e_datalist__title" style={{ flexBasis: titleWidth }}>{ item.title }</div>
<div className="_e_datalist__value">{ item.value }</div>
Expand Down
5 changes: 3 additions & 2 deletions src/packages/core/src/radio-group/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export const RadioGroup = (props: RadioGroupProps) => {
}
};

const renderOptions = options.map((option) => (
const renderOptions = options.map((option, index) => (
<Radio
key={option.value}
key={`${option.value}-${index}`}
label={option.title}
description={option.description}
checked={option.value === value}
Expand All @@ -44,6 +44,7 @@ export const RadioGroup = (props: RadioGroupProps) => {

return (
<Fieldset
role="radiogroup"
className={className}
id={id}
legend={legend}
Expand Down

0 comments on commit 3b8f517

Please sign in to comment.