mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 17:53:00 +02:00
CODEBASE: Add custom useRerender hook (#359)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* This is the component for displaying a single faction's UI, not the list of all
|
||||
* accessible factions
|
||||
*/
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState } from "react";
|
||||
|
||||
import { AugmentationsPage } from "./AugmentationsPage";
|
||||
import { DonateOption } from "./DonateOption";
|
||||
@@ -25,6 +25,7 @@ import { FactionNames } from "../data/FactionNames";
|
||||
import { GangButton } from "./GangButton";
|
||||
import { FactionWork } from "../../Work/FactionWork";
|
||||
import { FactionWorkType } from "../../Enums";
|
||||
import { useRerender } from "../../ui/React/hooks";
|
||||
|
||||
type IProps = {
|
||||
faction: Faction;
|
||||
@@ -152,18 +153,9 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea
|
||||
}
|
||||
|
||||
export function FactionRoot(props: IProps): React.ReactElement {
|
||||
const setRerender = useState(false)[1];
|
||||
const rerender = useRerender(200);
|
||||
const [purchasingAugs, setPurchasingAugs] = useState(props.augPage);
|
||||
|
||||
function rerender(): void {
|
||||
setRerender((old) => !old);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const id = setInterval(rerender, 200);
|
||||
return () => clearInterval(id);
|
||||
}, []);
|
||||
|
||||
const faction = props.faction;
|
||||
|
||||
if (!Player.factions.includes(faction.name)) {
|
||||
|
||||
Reference in New Issue
Block a user