diff --git a/lib/anonymous.js b/lib/anonymous.js index 16d95543..663a1c37 100644 --- a/lib/anonymous.js +++ b/lib/anonymous.js @@ -43,12 +43,16 @@ export const useAnonymous = (fn, options = defaultOptions) => { const invoice = data?.createInvoice useEffect(() => { if (invoice) { + // fix for bug where `showModal` runs the code for two modals and thus executes `onSuccess` twice + let called = false showModal(onClose => { setTimeout(async () => { + if (called) return + called = true await fn(satsReceived, ...fnArgs, invoice.hash) onClose() }, 2000)