mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
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:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user