Skip to content

Commit

Permalink
🚨 Add a new key to each element in the beacon/device list
Browse files Browse the repository at this point in the history
Without this change, we get an error

```
Warning: Each child in a list should have a unique "key" prop.

Check the render method of `BluetoothCardList`. See https://reactjs.org/link/warning-keys for more information.
BluetoothCard@ionic://localhost/dist/bundle.js:21253:18
BluetoothCardList@ionic://localhost/dist/bundle.js:21666:21
```

With this change, the error does not occur
  • Loading branch information
shankari committed Mar 28, 2024
1 parent d0ed16b commit 48f4847
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions www/js/bluetooth/BluetoothScanPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const BluetoothScanPage = ({ ...props }: any) => {
<div>
{devices.map((device) => {
if (device) {
return <BluetoothCard device={device} isClassic={isClassic} />;
return <BluetoothCard device={device} isClassic={isClassic} key={device.id} />;
}
return null;
})}
Expand All @@ -188,7 +188,7 @@ const BluetoothScanPage = ({ ...props }: any) => {
<div>
{beaconsAsArray.map((beacon) => {
if (beacon) {
return <BluetoothCard device={beacon} isScanningBLE={isScanningBLE} />;
return <BluetoothCard device={beacon} isScanningBLE={isScanningBLE} key={beacon.uuid} />;
}
})}
</div>
Expand Down

0 comments on commit 48f4847

Please sign in to comment.