From 569bdb8c5d7538fa0ea8a99ff2f8376f7cbfa51a Mon Sep 17 00:00:00 2001 From: piotrruss Date: Mon, 6 Sep 2021 23:13:22 +0200 Subject: added stadard linter --- hooks/usePopup.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'hooks/usePopup.js') 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 ( - - {children} - - ) + return ( + + {children} + + ) } const usePopup = () => useContext(PopupContext) -- cgit v1.2.3