forked from mosip/inji-wallet
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mosip#625):[Tilak|Adityan] show saving overlay only after 1sec
- Loading branch information
1 parent
79e6627
commit 45e4cc1
Showing
4 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const useOverlayVisibleAfterTimeout = ( | ||
visibleStart = false, | ||
ms = 1000 | ||
) => { | ||
const [visible, setVisible] = useState(false); | ||
const [savingTimeout, setSavingTimeout] = useState(null); | ||
|
||
useEffect(() => { | ||
if (visibleStart) { | ||
const timeout = setTimeout(() => { | ||
setVisible(true); | ||
}, ms); | ||
setSavingTimeout(timeout); | ||
} else { | ||
clearTimeout(savingTimeout); | ||
setVisible(false); | ||
} | ||
}, [visibleStart]); | ||
|
||
return visible; | ||
}; |