mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-19 07:48:37 +02:00
CODEBASE: Add custom useRerender hook (#359)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import { find } from "lodash";
|
||||
|
||||
import { Box, Typography, Button, Container, Paper } from "@mui/material";
|
||||
@@ -11,14 +11,12 @@ import { Settings } from "../../Settings/Settings";
|
||||
|
||||
import { Programs } from "../Programs";
|
||||
import { CreateProgramWork } from "../../Work/CreateProgramWork";
|
||||
import { useRerender } from "../../ui/React/hooks";
|
||||
|
||||
export const ProgramsSeen: string[] = [];
|
||||
|
||||
export function ProgramsRoot(): React.ReactElement {
|
||||
const setRerender = useState(false)[1];
|
||||
function rerender(): void {
|
||||
setRerender((old) => !old);
|
||||
}
|
||||
useRerender(200);
|
||||
|
||||
const programs = [...Object.values(Programs)]
|
||||
.filter((prog) => {
|
||||
@@ -42,11 +40,6 @@ export function ProgramsRoot(): React.ReactElement {
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const id = setInterval(rerender, 200);
|
||||
return () => clearInterval(id);
|
||||
}, []);
|
||||
|
||||
const getHackingLevelRemaining = (lvl: number): number => {
|
||||
return Math.ceil(Math.max(lvl - (Player.skills.hacking + Player.skills.intelligence / 2), 0));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user