Ensure a unique ID for supply routes.

List indexes are not a reliable list key unless the list is static.
Indexes will be reused when games are loaded, which prevents the state
from updating reliably.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2167
This commit is contained in:
Dan Albert
2022-05-29 14:07:40 -07:00
parent 046c863768
commit c5efc908de
3 changed files with 19 additions and 2 deletions

View File

@@ -428,6 +428,7 @@ export type Tgo = {
sidc: string;
};
export type SupplyRoute = {
id: string;
points: LatLng[];
front_active: boolean;
is_sea: boolean;

View File

@@ -7,8 +7,8 @@ export default function SupplyRoutesLayer() {
const routes = useAppSelector(selectSupplyRoutes).routes;
return (
<LayerGroup>
{routes.map((route, idx) => {
return <SupplyRoute key={idx} route={route} />;
{routes.map((route) => {
return <SupplyRoute key={route.id} route={route} />;
})}
</LayerGroup>
);