aboutsummaryrefslogtreecommitdiffstats
path: root/hooks/usePopup.js
diff options
context:
space:
mode:
Diffstat (limited to 'hooks/usePopup.js')
-rw-r--r--hooks/usePopup.js25
1 files changed, 12 insertions, 13 deletions
diff --git a/hooks/usePopup.js b/hooks/usePopup.js
index 615d403..c1fca19 100644
--- a/hooks/usePopup.js
+++ b/hooks/usePopup.js
@@ -3,35 +3,34 @@ import Queue from 'helpers/queue'
const PopupContext = createContext()
-export const PopupProvider = ({children}) => {
+export const PopupProvider = ({ children }) => {
const [popupData, setPopupData] = useState()
const setPopup = p => {
Queue.enqueue(
() =>
- new Promise(r => {
+ new Promise(resolve => {
if (p.time) {
setPopupData(p)
setTimeout(() => {
- r(setPopupData());
- }, p.time);
+ resolve(setPopupData())
+ }, p.time)
} else {
setPopupData({
...p,
- ...(p.yes && {yes: {label: p.yes.label, action: () => p.yes.action().then(() => r(setPopupData()))}}),
- ...(p.no && {no: {label: p.no.label, action: () => p.no.action().then(() => {r(setPopupData())})}}),
+ ...(p.yes && { yes: { label: p.yes.label, action: () => p.yes.action().then(() => resolve(setPopupData())) } }),
+ ...(p.no && { no: { label: p.no.label, action: () => p.no.action().then(() => { resolve(setPopupData()) }) } })
})
}
})
- );
-
+ )
}
- return (
- <PopupContext.Provider value={{popupData, setPopup}}>
- {children}
- </PopupContext.Provider>
- )
+ return (
+ <PopupContext.Provider value={{ popupData, setPopup }}>
+ {children}
+ </PopupContext.Provider>
+ )
}
const usePopup = () => useContext(PopupContext)