mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 00:32:51 +02:00
INFILTRATION: Fix React warnings (#1423)
This commit is contained in:
@@ -5,15 +5,23 @@ interface IProps {
|
||||
onFinish: () => void;
|
||||
}
|
||||
|
||||
export function Countdown(props: IProps): React.ReactElement {
|
||||
export function Countdown({ onFinish }: IProps): React.ReactElement {
|
||||
const [x, setX] = useState(3);
|
||||
|
||||
useEffect(() => {
|
||||
if (x === 0) {
|
||||
props.onFinish();
|
||||
return;
|
||||
onFinish();
|
||||
}
|
||||
setTimeout(() => setX(x - 1), 300);
|
||||
});
|
||||
}, [x, onFinish]);
|
||||
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => {
|
||||
setX((previousValue) => previousValue - 1);
|
||||
}, 300);
|
||||
return () => {
|
||||
clearInterval(id);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Paper sx={{ p: 1, textAlign: "center" }}>
|
||||
|
||||
Reference in New Issue
Block a user