mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-03 20:07:34 +01:00
Merge pull request #4161 from Snarling/cityFix
UI: Fix possible React error 300 in ASCII version of city screen
This commit is contained in:
commit
49a460af00
@ -47,9 +47,7 @@ function toLocation(location: Location): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function LocationLetter(location: Location): React.ReactElement {
|
function LocationLetter(location: Location, className: string): React.ReactElement {
|
||||||
location.types;
|
|
||||||
const classes = useStyles();
|
|
||||||
let L = "X";
|
let L = "X";
|
||||||
if (location.types.includes(LocationType.Company)) L = "C";
|
if (location.types.includes(LocationType.Company)) L = "C";
|
||||||
if (location.types.includes(LocationType.Gym)) L = "G";
|
if (location.types.includes(LocationType.Gym)) L = "G";
|
||||||
@ -63,12 +61,7 @@ function LocationLetter(location: Location): React.ReactElement {
|
|||||||
if (location.types.includes(LocationType.Special)) L = "?";
|
if (location.types.includes(LocationType.Special)) L = "?";
|
||||||
if (!location) return <span>*</span>;
|
if (!location) return <span>*</span>;
|
||||||
return (
|
return (
|
||||||
<span
|
<span aria-label={location.name} key={location.name} className={className} onClick={() => toLocation(location)}>
|
||||||
aria-label={location.name}
|
|
||||||
key={location.name}
|
|
||||||
className={classes.location}
|
|
||||||
onClick={() => toLocation(location)}
|
|
||||||
>
|
|
||||||
<b>{L}</b>
|
<b>{L}</b>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
@ -106,6 +99,7 @@ function ASCIICity(props: IProps): React.ReactElement {
|
|||||||
Y: 24,
|
Y: 24,
|
||||||
Z: 25,
|
Z: 25,
|
||||||
};
|
};
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
const lineElems = (s: string): (string | React.ReactElement)[] => {
|
const lineElems = (s: string): (string | React.ReactElement)[] => {
|
||||||
const elems: (string | React.ReactElement)[] = [];
|
const elems: (string | React.ReactElement)[] = [];
|
||||||
@ -124,7 +118,7 @@ function ASCIICity(props: IProps): React.ReactElement {
|
|||||||
const endI = matches[i].index;
|
const endI = matches[i].index;
|
||||||
elems.push(s.slice(startI, endI));
|
elems.push(s.slice(startI, endI));
|
||||||
const locationI = letterMap[s[matches[i].index]];
|
const locationI = letterMap[s[matches[i].index]];
|
||||||
elems.push(LocationLetter(Locations[props.city.locations[locationI]]));
|
elems.push(LocationLetter(Locations[props.city.locations[locationI]], classes.location));
|
||||||
}
|
}
|
||||||
elems.push(s.slice(matches[matches.length - 1].index + 1));
|
elems.push(s.slice(matches[matches.length - 1].index + 1));
|
||||||
return elems;
|
return elems;
|
||||||
|
Loading…
Reference in New Issue
Block a user