fix: prevent useCloseOnSuccessNotification from firing on mount

The hook checked closeOthersSignal > 0 which only skipped signal=0.
After first payment, signal stays at 1+ forever causing TopUpAmount
to immediately navigate away on every mount. Now tracks the signal
value at mount time and only reacts to changes after mount.
This commit is contained in:
Fringg
2026-02-09 05:53:33 +03:00
parent 0c34668e40
commit 0389acdf83

View File

@@ -67,9 +67,11 @@ export function useCloseOnSuccessNotification(onClose: () => void) {
const onCloseRef = useRef(onClose);
onCloseRef.current = onClose;
// Remember the signal value at mount time so we only react to NEW signals
const mountedSignalRef = useRef(closeOthersSignal);
useEffect(() => {
// Skip the initial render (signal = 0)
if (closeOthersSignal > 0) {
if (closeOthersSignal !== mountedSignalRef.current) {
onCloseRef.current();
}
}, [closeOthersSignal]);