import React, { useState, useEffect } from "react"; import Grid from "@mui/material/Grid"; import Typography from "@mui/material/Typography"; interface IProps { onFinish: () => void; } export function Countdown(props: IProps): React.ReactElement { const [x, setX] = useState(3); useEffect(() => { if (x === 0) { props.onFinish(); return; } setTimeout(() => setX(x - 1), 200); }); return ( <> Get Ready! {x} ); }