Update HospitalLocation.tsx

Add auto-refreshing to the component
This commit is contained in:
borisflagell 2022-10-14 14:13:53 +03:00
parent 1b61ec0e12
commit baa149fa80

@ -12,17 +12,21 @@ import { getHospitalizationCost } from "../../Hospital/Hospital";
import { Money } from "../../ui/React/Money"; import { Money } from "../../ui/React/Money";
import { dialogBoxCreate } from "../../ui/React/DialogBox"; import { dialogBoxCreate } from "../../ui/React/DialogBox";
import { useState } from "react"; import { useEffect, useState } from "react";
export function HospitalLocation(): React.ReactElement { export function HospitalLocation(): React.ReactElement {
/** Stores button styling that sets them all to block display */ /** Stores button styling that sets them all to block display */
const btnStyle = { display: "block" }; const btnStyle = { display: "block" };
const setRerender = useState(false)[1]; const setRerender = useState(false)[1];
function rerender(): void { function rerender(): void {
setRerender((old) => !old); setRerender((old) => !old);
} }
useEffect(() => {
const id = setInterval(rerender, 200);
return () => clearInterval(id);
}, []);
function getHealed(e: React.MouseEvent<HTMLElement>): void { function getHealed(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) { if (!e.isTrusted) {
return; return;