Skip to content

Commit

Permalink
fix: clear TxButton complete timeout on unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
chmanie committed Jul 25, 2024
1 parent 6e00e00 commit f1d4cf4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/v5/shared/TxButton/TxButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const TxButton: FC = () => {

// Shows the "Completed" messasge just a little longer after all transactions are completed
useEffect(() => {
let timeoutId: NodeJS.Timeout;
if (groupState === TransactionGroupStatus.Pending) {
setShowPending(true);
} else if (
Expand All @@ -60,10 +61,11 @@ const TxButton: FC = () => {
) {
setShowPending(false);
setShowCompleted(true);
setTimeout(() => {
timeoutId = setTimeout(() => {
setShowCompleted(false);
}, 5000);
}
return () => clearTimeout(timeoutId);
}, [groupState, prevGroupState]);

if (showPending) {
Expand Down

0 comments on commit f1d4cf4

Please sign in to comment.