mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-04 22:59:42 +02:00
CODEBASE: Add custom useRerender hook (#359)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { CheckBox, CheckBoxOutlineBlank, Construction } from "@mui/icons-material";
|
||||
import { Box, Button, Container, List, ListItemButton, Paper, Typography } from "@mui/material";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import React, { useState } from "react";
|
||||
import { GraftingWork } from "../../../Work/GraftingWork";
|
||||
import { Augmentation } from "../../../Augmentation/Augmentation";
|
||||
import { AugmentationNames } from "../../../Augmentation/data/AugmentationNames";
|
||||
@@ -20,6 +20,7 @@ import { convertTimeMsToTimeElapsedString } from "../../../utils/StringHelperFun
|
||||
import { Player } from "@player";
|
||||
import { GraftableAugmentation } from "../GraftableAugmentation";
|
||||
import { calculateGraftingTimeWithBonus, getGraftingAvailableAugs } from "../GraftingHelpers";
|
||||
import { useRerender } from "../../../ui/React/hooks";
|
||||
|
||||
export const GraftableAugmentations = (): Record<string, GraftableAugmentation> => {
|
||||
const gAugs: Record<string, GraftableAugmentation> = {};
|
||||
@@ -65,11 +66,7 @@ export const GraftingRoot = (): React.ReactElement => {
|
||||
const [selectedAug, setSelectedAug] = useState(getGraftingAvailableAugs()[0]);
|
||||
const [graftOpen, setGraftOpen] = useState(false);
|
||||
const selectedAugmentation = StaticAugmentations[selectedAug];
|
||||
|
||||
const setRerender = useState(false)[1];
|
||||
function rerender(): void {
|
||||
setRerender((old) => !old);
|
||||
}
|
||||
const rerender = useRerender(200);
|
||||
|
||||
const getAugsSorted = (): string[] => {
|
||||
const augs = getGraftingAvailableAugs();
|
||||
@@ -86,11 +83,6 @@ export const GraftingRoot = (): React.ReactElement => {
|
||||
rerender();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const id = setInterval(rerender, 200);
|
||||
return () => clearInterval(id);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Container disableGutters maxWidth="lg" sx={{ mx: 0 }}>
|
||||
<Button onClick={() => Router.toLocation(Locations[LocationName.NewTokyoVitaLife])}>Back</Button>
|
||||
|
||||
Reference in New Issue
Block a user