bitburner-src/src/Infiltration/ui/Countdown.tsx

29 lines
543 B
TypeScript
Raw Normal View History

2021-09-05 01:09:30 +02:00
import React, { useState, useEffect } from "react";
2021-09-17 01:23:03 +02:00
import Grid from "@mui/material/Grid";
interface IProps {
2021-09-05 01:09:30 +02:00
onFinish: () => void;
}
export function Countdown(props: IProps): React.ReactElement {
2021-09-05 01:09:30 +02:00
const [x, setX] = useState(3);
useEffect(() => {
if (x === 0) {
props.onFinish();
return;
}
setTimeout(() => setX(x - 1), 200);
});
2021-09-05 01:09:30 +02:00
return (
<>
<Grid container spacing={3}>
<Grid item xs={12}>
<h1>Get Ready!</h1>
<h1>{x}</h1>
</Grid>
2021-09-05 01:09:30 +02:00
</Grid>
</>
);
}