---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: noArrayIndexKey.jsx
---
# Input
```jsx
import { Children, cloneElement } from "react";
something.forEach((Element, index) => {
foo;
});
something.forEach((element, index, array) => {
foo;
});
things.filter((thing, index) => {
otherThings.push(foo);
});
something.forEach((Element, index) => {
;
});
something.forEach((element, index, array) => {
;
});
things.filter((thing, index) => {
otherThings.push();
});
things.reduce(
(collection, thing, index) => collection.concat(),
[]
);
React.Children.map(this.props.children, (child, index) =>
React.cloneElement(child, { key: index })
);
React.Children.forEach(this.props.children, function (child, index) {
return React.cloneElement(child, { key: index });
});
Children.map(this.props.children, (child, index) =>
cloneElement(child, { key: index })
);
Children.forEach(this.props.children, function (child, index) {
return cloneElement(child, { key: index });
});
Children.forEach(this.props.children, function (child, index) {
const foo = cloneElement(child, { key: index });
return foo;
});
function Test(props) {
return Children.map(props.children, function (child, index) {
return cloneElement(child, { key: index });
});
}
things.map((thing, index) => React.cloneElement(thing, { key: index }));
things.flatMap((thing, index) => {
return ;
});
Array.from(things, (thing, index) => {
return ;
});
const mapping = {
foo: () => things.map((_, index) => ),
};
class A extends React.Component {
renderThings = () => things.map((_, index) => );
}
const Component1 = () => things.map((_, index) => );
const Component2 = () => things.map((_, index) => );
function Component3() {
return things.map((_, index) => );
}
function Component4() {
let elements = things.map((_, index) => );
if (condition) {
elements = others.map((_, index) => );
}
return elements;
}
function Component5({ things }) {
const elements = useMemo(
() => things.map((_, index) => ),
[things]
);
return elements;
}
function Component6({ things }) {
const elements = useMemo(
() => things.map((_, index) => ),
[things]
);
return elements;
}
function Component7() {
return (
{({ things }) => things.map((_, index) => )}
);
}
```
# Diagnostics
```
noArrayIndexKey.jsx:4:18 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
3 │ something.forEach((Element, index) => {
> 4 │ foo;
│ ^^^^^
5 │ });
6 │ something.forEach((element, index, array) => {
i This is the source of the key value.
1 │ import { Children, cloneElement } from "react";
2 │
> 3 │ something.forEach((Element, index) => {
│ ^^^^^
4 │ foo;
5 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
2 2 │
3 3 │ something.forEach((Element, index) => {
4 │ - → foo;
4 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
5 │ + foo;
5 6 │ });
6 7 │ something.forEach((element, index, array) => {
```
```
noArrayIndexKey.jsx:7:18 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
5 │ });
6 │ something.forEach((element, index, array) => {
> 7 │ foo;
│ ^^^^^
8 │ });
9 │ things.filter((thing, index) => {
i This is the source of the key value.
4 │ foo;
5 │ });
> 6 │ something.forEach((element, index, array) => {
│ ^^^^^
7 │ foo;
8 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
5 5 │ });
6 6 │ something.forEach((element, index, array) => {
7 │ - → foo;
7 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
8 │ + foo;
8 9 │ });
9 10 │ things.filter((thing, index) => {
```
```
noArrayIndexKey.jsx:10:31 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
8 │ });
9 │ things.filter((thing, index) => {
> 10 │ otherThings.push(foo);
│ ^^^^^
11 │ });
12 │
i This is the source of the key value.
7 │ foo;
8 │ });
> 9 │ things.filter((thing, index) => {
│ ^^^^^
10 │ otherThings.push(foo);
11 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
8 8 │ });
9 9 │ things.filter((thing, index) => {
10 │ - → otherThings.push(foo);
10 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
11 │ + → otherThings.push(foo);
11 12 │ });
12 13 │
```
```
noArrayIndexKey.jsx:14:18 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
13 │ something.forEach((Element, index) => {
> 14 │ ;
│ ^^^^^
15 │ });
16 │ something.forEach((element, index, array) => {
i This is the source of the key value.
11 │ });
12 │
> 13 │ something.forEach((Element, index) => {
│ ^^^^^
14 │ ;
15 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
12 12 │
13 13 │ something.forEach((Element, index) => {
14 │ - → ;
14 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
15 │ + ;
15 16 │ });
16 17 │ something.forEach((element, index, array) => {
```
```
noArrayIndexKey.jsx:17:18 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
15 │ });
16 │ something.forEach((element, index, array) => {
> 17 │ ;
│ ^^^^^
18 │ });
19 │ things.filter((thing, index) => {
i This is the source of the key value.
14 │ ;
15 │ });
> 16 │ something.forEach((element, index, array) => {
│ ^^^^^
17 │ ;
18 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
15 15 │ });
16 16 │ something.forEach((element, index, array) => {
17 │ - → ;
17 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
18 │ + ;
18 19 │ });
19 20 │ things.filter((thing, index) => {
```
```
noArrayIndexKey.jsx:20:31 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
18 │ });
19 │ things.filter((thing, index) => {
> 20 │ otherThings.push();
│ ^^^^^
21 │ });
22 │ things.reduce(
i This is the source of the key value.
17 │ ;
18 │ });
> 19 │ things.filter((thing, index) => {
│ ^^^^^
20 │ otherThings.push();
21 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
18 18 │ });
19 19 │ things.filter((thing, index) => {
20 │ - → otherThings.push();
20 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
21 │ + → otherThings.push();
21 22 │ });
22 23 │ things.reduce(
```
```
noArrayIndexKey.jsx:23:62 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
21 │ });
22 │ things.reduce(
> 23 │ (collection, thing, index) => collection.concat(),
│ ^^^^^
24 │ []
25 │ );
i This is the source of the key value.
21 │ });
22 │ things.reduce(
> 23 │ (collection, thing, index) => collection.concat(),
│ ^^^^^
24 │ []
25 │ );
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
21 21 │ });
22 22 │ things.reduce(
23 │ - → (collection,·thing,·index)·=>·collection.concat(),
23 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
24 │ + → (collection,·thing,·index)·=>·collection.concat(),
24 25 │ []
25 26 │ );
```
```
noArrayIndexKey.jsx:28:35 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
27 │ React.Children.map(this.props.children, (child, index) =>
> 28 │ React.cloneElement(child, { key: index })
│ ^^^^^
29 │ );
30 │
i This is the source of the key value.
25 │ );
26 │
> 27 │ React.Children.map(this.props.children, (child, index) =>
│ ^^^^^
28 │ React.cloneElement(child, { key: index })
29 │ );
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
26 26 │
27 27 │ React.Children.map(this.props.children, (child, index) =>
28 │ - → React.cloneElement(child,·{·key:·index·})
28 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
29 │ + → React.cloneElement(child,·{·key:·index·})
29 30 │ );
30 31 │
```
```
noArrayIndexKey.jsx:32:42 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
31 │ React.Children.forEach(this.props.children, function (child, index) {
> 32 │ return React.cloneElement(child, { key: index });
│ ^^^^^
33 │ });
34 │
i This is the source of the key value.
29 │ );
30 │
> 31 │ React.Children.forEach(this.props.children, function (child, index) {
│ ^^^^^
32 │ return React.cloneElement(child, { key: index });
33 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
30 30 │
31 31 │ React.Children.forEach(this.props.children, function (child, index) {
32 │ - → return·React.cloneElement(child,·{·key:·index·});
32 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
33 │ + → return·React.cloneElement(child,·{·key:·index·});
33 34 │ });
34 35 │
```
```
noArrayIndexKey.jsx:36:29 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
35 │ Children.map(this.props.children, (child, index) =>
> 36 │ cloneElement(child, { key: index })
│ ^^^^^
37 │ );
38 │
i This is the source of the key value.
33 │ });
34 │
> 35 │ Children.map(this.props.children, (child, index) =>
│ ^^^^^
36 │ cloneElement(child, { key: index })
37 │ );
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
34 34 │
35 35 │ Children.map(this.props.children, (child, index) =>
36 │ - → cloneElement(child,·{·key:·index·})
36 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
37 │ + → cloneElement(child,·{·key:·index·})
37 38 │ );
38 39 │
```
```
noArrayIndexKey.jsx:40:36 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
39 │ Children.forEach(this.props.children, function (child, index) {
> 40 │ return cloneElement(child, { key: index });
│ ^^^^^
41 │ });
42 │
i This is the source of the key value.
37 │ );
38 │
> 39 │ Children.forEach(this.props.children, function (child, index) {
│ ^^^^^
40 │ return cloneElement(child, { key: index });
41 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
38 38 │
39 39 │ Children.forEach(this.props.children, function (child, index) {
40 │ - → return·cloneElement(child,·{·key:·index·});
40 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
41 │ + → return·cloneElement(child,·{·key:·index·});
41 42 │ });
42 43 │
```
```
noArrayIndexKey.jsx:44:41 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
43 │ Children.forEach(this.props.children, function (child, index) {
> 44 │ const foo = cloneElement(child, { key: index });
│ ^^^^^
45 │ return foo;
46 │ });
i This is the source of the key value.
41 │ });
42 │
> 43 │ Children.forEach(this.props.children, function (child, index) {
│ ^^^^^
44 │ const foo = cloneElement(child, { key: index });
45 │ return foo;
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
42 42 │
43 43 │ Children.forEach(this.props.children, function (child, index) {
44 │ - → const·foo·=·cloneElement(child,·{·key:·index·});
44 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
45 │ + → const·foo·=·cloneElement(child,·{·key:·index·});
45 46 │ return foo;
46 47 │ });
```
```
noArrayIndexKey.jsx:50:37 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
48 │ function Test(props) {
49 │ return Children.map(props.children, function (child, index) {
> 50 │ return cloneElement(child, { key: index });
│ ^^^^^
51 │ });
52 │ }
i This is the source of the key value.
48 │ function Test(props) {
> 49 │ return Children.map(props.children, function (child, index) {
│ ^^^^^
50 │ return cloneElement(child, { key: index });
51 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
48 48 │ function Test(props) {
49 49 │ return Children.map(props.children, function (child, index) {
50 │ - → → return·cloneElement(child,·{·key:·index·});
50 │ + → → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
51 │ + → → return·cloneElement(child,·{·key:·index·});
51 52 │ });
52 53 │ }
```
```
noArrayIndexKey.jsx:54:63 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
52 │ }
53 │
> 54 │ things.map((thing, index) => React.cloneElement(thing, { key: index }));
│ ^^^^^
55 │
56 │ things.flatMap((thing, index) => {
i This is the source of the key value.
52 │ }
53 │
> 54 │ things.map((thing, index) => React.cloneElement(thing, { key: index }));
│ ^^^^^
55 │
56 │ things.flatMap((thing, index) => {
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
52 52 │ }
53 53 │
54 │ + //·biome-ignore·lint/suspicious/noArrayIndexKey:·
54 55 │ things.map((thing, index) => React.cloneElement(thing, { key: index }));
55 56 │
```
```
noArrayIndexKey.jsx:57:25 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
56 │ things.flatMap((thing, index) => {
> 57 │ return ;
│ ^^^^^
58 │ });
59 │
i This is the source of the key value.
54 │ things.map((thing, index) => React.cloneElement(thing, { key: index }));
55 │
> 56 │ things.flatMap((thing, index) => {
│ ^^^^^
57 │ return ;
58 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
55 55 │
56 56 │ things.flatMap((thing, index) => {
57 │ - → return·;
57 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
58 │ + → return·;
58 59 │ });
59 60 │
```
```
noArrayIndexKey.jsx:61:25 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
60 │ Array.from(things, (thing, index) => {
> 61 │ return ;
│ ^^^^^
62 │ });
63 │
i This is the source of the key value.
58 │ });
59 │
> 60 │ Array.from(things, (thing, index) => {
│ ^^^^^
61 │ return ;
62 │ });
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
59 59 │
60 60 │ Array.from(things, (thing, index) => {
61 │ - → return·;
61 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
62 │ + → return·;
62 63 │ });
63 64 │
```
```
noArrayIndexKey.jsx:65:54 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
64 │ const mapping = {
> 65 │ foo: () => things.map((_, index) => ),
│ ^^^^^
66 │ };
67 │
i This is the source of the key value.
64 │ const mapping = {
> 65 │ foo: () => things.map((_, index) => ),
│ ^^^^^
66 │ };
67 │
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
63 63 │
64 64 │ const mapping = {
65 │ - → foo:·()·=>·things.map((_,·index)·=>·),
65 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
66 │ + → foo:·()·=>·things.map((_,·index)·=>·),
66 67 │ };
67 68 │
```
```
noArrayIndexKey.jsx:69:64 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
68 │ class A extends React.Component {
> 69 │ renderThings = () => things.map((_, index) => );
│ ^^^^^
70 │ }
71 │
i This is the source of the key value.
68 │ class A extends React.Component {
> 69 │ renderThings = () => things.map((_, index) => );
│ ^^^^^
70 │ }
71 │
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
67 67 │
68 68 │ class A extends React.Component {
69 │ - → renderThings·=·()·=>·things.map((_,·index)·=>·);
69 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
70 │ + → renderThings·=·()·=>·things.map((_,·index)·=>·);
70 71 │ }
71 72 │
```
```
noArrayIndexKey.jsx:72:67 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
70 │ }
71 │
> 72 │ const Component1 = () => things.map((_, index) => );
│ ^^^^^
73 │
74 │ const Component2 = () => things.map((_, index) => );
i This is the source of the key value.
70 │ }
71 │
> 72 │ const Component1 = () => things.map((_, index) => );
│ ^^^^^
73 │
74 │ const Component2 = () => things.map((_, index) => );
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
70 70 │ }
71 71 │
72 │ + //·biome-ignore·lint/suspicious/noArrayIndexKey:·
72 73 │ const Component1 = () => things.map((_, index) => );
73 74 │
```
```
noArrayIndexKey.jsx:74:67 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
72 │ const Component1 = () => things.map((_, index) => );
73 │
> 74 │ const Component2 = () => things.map((_, index) => );
│ ^^^^^
75 │
76 │ function Component3() {
i This is the source of the key value.
72 │ const Component1 = () => things.map((_, index) => );
73 │
> 74 │ const Component2 = () => things.map((_, index) => );
│ ^^^^^
75 │
76 │ function Component3() {
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
72 72 │ const Component1 = () => things.map((_, index) => );
73 73 │
74 │ + //·biome-ignore·lint/suspicious/noArrayIndexKey:·
74 75 │ const Component2 = () => things.map((_, index) => );
75 76 │
```
```
noArrayIndexKey.jsx:77:50 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
76 │ function Component3() {
> 77 │ return things.map((_, index) => );
│ ^^^^^
78 │ }
79 │
i This is the source of the key value.
76 │ function Component3() {
> 77 │ return things.map((_, index) => );
│ ^^^^^
78 │ }
79 │
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
75 75 │
76 76 │ function Component3() {
77 │ - → return·things.map((_,·index)·=>·);
77 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
78 │ + → return·things.map((_,·index)·=>·);
78 79 │ }
79 80 │
```
```
noArrayIndexKey.jsx:81:58 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
80 │ function Component4() {
> 81 │ let elements = things.map((_, index) => );
│ ^^^^^
82 │ if (condition) {
83 │ elements = others.map((_, index) => );
i This is the source of the key value.
80 │ function Component4() {
> 81 │ let elements = things.map((_, index) => );
│ ^^^^^
82 │ if (condition) {
83 │ elements = others.map((_, index) => );
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
79 79 │
80 80 │ function Component4() {
81 │ - → let·elements·=·things.map((_,·index)·=>·);
81 │ + → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
82 │ + → let·elements·=·things.map((_,·index)·=>·);
82 83 │ if (condition) {
83 84 │ elements = others.map((_, index) => );
```
```
noArrayIndexKey.jsx:83:55 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
81 │ let elements = things.map((_, index) => );
82 │ if (condition) {
> 83 │ elements = others.map((_, index) => );
│ ^^^^^
84 │ }
85 │ return elements;
i This is the source of the key value.
81 │ let elements = things.map((_, index) => );
82 │ if (condition) {
> 83 │ elements = others.map((_, index) => );
│ ^^^^^
84 │ }
85 │ return elements;
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
81 81 │ let elements = things.map((_, index) => );
82 82 │ if (condition) {
83 │ - → → elements·=·others.map((_,·index)·=>·);
83 │ + → → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
84 │ + → → elements·=·others.map((_,·index)·=>·);
84 85 │ }
85 86 │ return elements;
```
```
noArrayIndexKey.jsx:90:50 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
88 │ function Component5({ things }) {
89 │ const elements = useMemo(
> 90 │ () => things.map((_, index) => ),
│ ^^^^^
91 │ [things]
92 │ );
i This is the source of the key value.
88 │ function Component5({ things }) {
89 │ const elements = useMemo(
> 90 │ () => things.map((_, index) => ),
│ ^^^^^
91 │ [things]
92 │ );
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
88 88 │ function Component5({ things }) {
89 89 │ const elements = useMemo(
90 │ - → → ()·=>·things.map((_,·index)·=>·),
90 │ + → → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
91 │ + → → ()·=>·things.map((_,·index)·=>·),
91 92 │ [things]
92 93 │ );
```
```
noArrayIndexKey.jsx:98:50 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
96 │ function Component6({ things }) {
97 │ const elements = useMemo(
> 98 │ () => things.map((_, index) => ),
│ ^^^^^
99 │ [things]
100 │ );
i This is the source of the key value.
96 │ function Component6({ things }) {
97 │ const elements = useMemo(
> 98 │ () => things.map((_, index) => ),
│ ^^^^^
99 │ [things]
100 │ );
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
96 96 │ function Component6({ things }) {
97 97 │ const elements = useMemo(
98 │ - → → ()·=>·things.map((_,·index)·=>·),
98 │ + → → //·biome-ignore·lint/suspicious/noArrayIndexKey:·
99 │ + → → ()·=>·things.map((_,·index)·=>·),
99 100 │ [things]
100 101 │ );
```
```
noArrayIndexKey.jsx:107:62 lint/suspicious/noArrayIndexKey FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Avoid using the index of an array as key property in an element.
105 │ return (
106 │
> 107 │ {({ things }) => things.map((_, index) => )}
│ ^^^^^
108 │
109 │ );
i This is the source of the key value.
105 │ return (
106 │
> 107 │ {({ things }) => things.map((_, index) => )}
│ ^^^^^
108 │
109 │ );
i The order of the items may change, and this also affects performances and component state.
i Check the React documentation.
i Safe fix: Suppress rule lint/suspicious/noArrayIndexKey
105 105 │ return (
106 106 │
107 │ - → → → {({·things·})·=>·things.map((_,·index)·=>·)}
107 │ + → → → {/*·biome-ignore·lint/suspicious/noArrayIndexKey:··*/}
108 │ + {({·things·})·=>·things.map((_,·index)·=>·)}
108 109 │
109 110 │ );
```