diff --git a/src/Locations/ui/CoresButton.tsx b/src/Locations/ui/CoresButton.tsx index 5eafd46a2..f66696d5a 100644 --- a/src/Locations/ui/CoresButton.tsx +++ b/src/Locations/ui/CoresButton.tsx @@ -9,14 +9,10 @@ import { MathComponent } from "mathjax-react"; type IProps = { p: IPlayer; + rerender: () => void; }; export function CoresButton(props: IProps): React.ReactElement { - const setRerender = useState(false)[1]; - function rerender(): void { - setRerender((old) => !old); - } - const btnStyle = { display: "block" }; const homeComputer = props.p.getHomeComputer(); @@ -37,7 +33,7 @@ export function CoresButton(props: IProps): React.ReactElement { if (!props.p.canAfford(cost)) return; props.p.loseMoney(cost); homeComputer.cpuCores++; - rerender(); + props.rerender(); } return ( diff --git a/src/Locations/ui/RamButton.tsx b/src/Locations/ui/RamButton.tsx index d98fabefe..fb63e8281 100644 --- a/src/Locations/ui/RamButton.tsx +++ b/src/Locations/ui/RamButton.tsx @@ -11,14 +11,10 @@ import { MathComponent } from "mathjax-react"; type IProps = { p: IPlayer; + rerender: () => void; }; export function RamButton(props: IProps): React.ReactElement { - const setRerender = useState(false)[1]; - function rerender(): void { - setRerender((old) => !old); - } - const btnStyle = { display: "block" }; const homeComputer = props.p.getHomeComputer(); @@ -32,7 +28,7 @@ export function RamButton(props: IProps): React.ReactElement { function buy(): void { purchaseRamForHomeComputer(props.p); - rerender(); + props.rerender(); } return ( diff --git a/src/Locations/ui/TechVendorLocation.tsx b/src/Locations/ui/TechVendorLocation.tsx index abbaaa42b..e111a3fa7 100644 --- a/src/Locations/ui/TechVendorLocation.tsx +++ b/src/Locations/ui/TechVendorLocation.tsx @@ -3,7 +3,7 @@ * * This subcomponent renders all of the buttons for purchasing things from tech vendors */ -import * as React from "react"; +import React, { useState } from "react"; import { Location } from "../Location"; import { createPurchaseServerPopup } from "../LocationsHelpers"; @@ -23,6 +23,10 @@ type IProps = { }; export function TechVendorLocation(props: IProps): React.ReactElement { + const setRerender = useState(false)[1]; + function rerender() { + setRerender((old) => !old); + } const btnStyle = { display: "block" }; const purchaseServerButtons: React.ReactNode[] = []; @@ -58,9 +62,9 @@ export function TechVendorLocation(props: IProps): React.ReactElement {