useDebouncedPress
Prevents accidental double-taps on navigation, form submission, and payment actions with configurable cooldown.
v0.2.0NativeWindStyleSheetiOSAndroidExpo Go
Installation
npx nativra-cli add use-debounced-pressWrites use-debounced-press.ts to hooks, rewrites imports to your aliases and records hashes in nativra.lock.json. Existing files are never overwritten without asking.
Want to try it first? Open it in the playground: a real React Native project in your browser, with this item installed by the CLI.
Usage
The useDebouncedPress hook wraps any onPress callback and ignores rapid consecutive taps within a configurable cooldown window (delayMs, default 500ms), preventing duplicate screen pushes or double form submissions.
Installation
npx nativra-cli add use-debounced-pressUsage
import { Pressable, Text } from "react-native";
import { useDebouncedPress } from "@/hooks/use-debounced-press";
export function CheckoutButton({ onPay }: { onPay: () => void }) {
const handlePress = useDebouncedPress(onPay, { delayMs: 600 });
return (
<Pressable
onPress={handlePress}
accessibilityRole="button"
className="h-11 px-5 rounded-xl bg-sky-600 items-center justify-center"
>
<Text className="text-white font-semibold">Pay Now</Text>
</Pressable>
);
}Source
Exactly what the CLI writes, before your import aliases are applied.