I am making a countdown app using react.
I am managed to create a countdown start from 180 seconds but I want to convert this minute base which starts from 03:00.
Here is the code
const Countdown: React.FC<ICountdownProps> = ({ setVerification, setTimeUp }) => {
const [seconds, setSeconds] = useState(180);
useEffect(() => {
if (seconds > 0) {
setTimeout(() => setSeconds(seconds - 1), 1000);
}
});
const notVerified = () => {
setVerification(false);
setTimeUp(true)
return ''
};
return (
<div style={{ position: "absolute", right: 0, bottom: 0, padding: "10px" }}>
{
seconds !== 0 ? fmtMSS(seconds) : notVerified()
}
</div>
);
};
export default Countdown;
Can I use moment.js to convert a single number of seconds into a string showing minutes and seconds?