From baa149fa80dd4ac3a2ba67c1bbafd7f0a7a48d70 Mon Sep 17 00:00:00 2001 From: borisflagell Date: Fri, 14 Oct 2022 14:13:53 +0300 Subject: [PATCH] Update HospitalLocation.tsx Add auto-refreshing to the component --- src/Locations/ui/HospitalLocation.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Locations/ui/HospitalLocation.tsx b/src/Locations/ui/HospitalLocation.tsx index a92c6a024..9039831bf 100644 --- a/src/Locations/ui/HospitalLocation.tsx +++ b/src/Locations/ui/HospitalLocation.tsx @@ -12,17 +12,21 @@ import { getHospitalizationCost } from "../../Hospital/Hospital"; import { Money } from "../../ui/React/Money"; import { dialogBoxCreate } from "../../ui/React/DialogBox"; -import { useState } from "react"; +import { useEffect, useState } from "react"; export function HospitalLocation(): React.ReactElement { /** Stores button styling that sets them all to block display */ const btnStyle = { display: "block" }; - const setRerender = useState(false)[1]; function rerender(): void { setRerender((old) => !old); } + useEffect(() => { + const id = setInterval(rerender, 200); + return () => clearInterval(id); + }, []); + function getHealed(e: React.MouseEvent): void { if (!e.isTrusted) { return;