mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 18:18:27 -05:00
refactor: simplify donation modal logic (#58280)
This commit is contained in:
committed by
GitHub
parent
9429f52fd4
commit
4eef3854c7
@@ -254,25 +254,16 @@ function DonationModalBody({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setSecondsRemaining(prevSeconds => {
|
||||
if (prevSeconds > 0) {
|
||||
return prevSeconds - 1;
|
||||
} else {
|
||||
setIsAnimationVisible(false);
|
||||
clearInterval(interval);
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
const intervalId = setInterval(() => {
|
||||
setSecondsRemaining(prevSeconds => prevSeconds - 1);
|
||||
}, 1000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (secondsRemaining === 0) {
|
||||
if (secondsRemaining <= 0) {
|
||||
setIsAnimationVisible(false);
|
||||
setCanClose(true);
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
return () => clearInterval(intervalId);
|
||||
}, [secondsRemaining, setCanClose]);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user