estatesfunding/ef-ui/src/components/Loadingredirect.jsx

23 lines
601 B
React
Raw Normal View History

2024-09-06 15:02:20 +00:00
import { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
const Loadingredirect = () => {
const [count, setCount] = useState(3);
const navigate = useNavigate();
useEffect(() => {
const interval = setInterval(() => {
setCount((currentCount) => --currentCount);
}, 1000);
count === 0 && navigate("/login");
return () => clearInterval(interval);
}, [count, navigate]);
return (
<div style={{ marginTop: "100px" }}>
<h5>Redirecting you in {count} seconds</h5>
</div>
);
}
export default Loadingredirect