diff options
author | 2021-09-06 23:13:22 +0200 | |
---|---|---|
committer | 2021-09-06 23:13:22 +0200 | |
commit | 569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a (patch) | |
tree | 8d1cb94a56d60b9d726222277b7516fc59895613 /hooks/usePopup.js | |
parent | 275bd1d0a9aea90696c145cf992d522a0d6b0aa8 (diff) | |
download | my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.tar.gz my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.tar.bz2 my_apps-569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a.zip |
added stadard linter
Diffstat (limited to 'hooks/usePopup.js')
-rw-r--r-- | hooks/usePopup.js | 25 |
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) |