fix repeated click duplicate pages (#43) #67

Merged
amit merged 1 commits from issue-43 into main 2026-10-20 04:36:03 +00:00
1 changed files with 30 additions and 1 deletions

View File

@ -1,5 +1,34 @@
import { Stack } from "expo-router";
import { router, Stack } from "expo-router";
import React from "react";
// ============================================================================
// GLOBAL NAVIGATION THROTTLE (Generic Fix for Repeated Click / Double Navigation)
// ============================================================================
const NAVIGATION_THROTTLE_MS = 700;
let lastNavigationTimestamp = 0;
const originalPush = router.push.bind(router);
const originalNavigate = router.navigate.bind(router);
router.push = ((...args: Parameters<typeof originalPush>) => {
const now = Date.now();
if (now - lastNavigationTimestamp < NAVIGATION_THROTTLE_MS) {
return;
}
lastNavigationTimestamp = now;
return originalPush(...args);
}) as typeof router.push;
router.navigate = ((...args: Parameters<typeof originalNavigate>) => {
const now = Date.now();
if (now - lastNavigationTimestamp < NAVIGATION_THROTTLE_MS) {
return;
}
lastNavigationTimestamp = now;
return originalNavigate(...args);
}) as typeof router.navigate;
// ============================================================================
import * as RN from "react-native";
import {
useFonts,