Hooks
A collection of custom React hooks to simplify common tasks. Located in src/hooks.
useCountdown
Manages a countdown timer with start, stop, and reset functionality. Useful for OTP inputs or temporary access tokens.
1import { useCountdown } from "@/hooks";23const { seconds, isActive, start, stop, reset } = useCountdown({4 initialSeconds: 30,5 onComplete: () => console.log("Done!"),6});78// Start the timer9start();1011// Display12<Text>{seconds}s remaining</Text>
useDebounce
Debounces a value by a specified delay. Essential for search inputs to avoid making API calls on every keystroke.
1import { useDebounce } from "@/hooks";2import { useState, useEffect } from "react";34const [search, setSearch] = useState("");5const debouncedSearch = useDebounce(search, 500);67useEffect(() => {8 // Only runs 500ms after the user stops typing9 if (debouncedSearch) {10 performSearch(debouncedSearch);11 }12}, [debouncedSearch]);
useIsFirstTime
A persistent boolean hook that tracks if the user is opening the app for the first time. Uses MMKV for storage. Great for showing onboarding screens.
1import { useIsFirstTime } from "@/hooks";23const [isFirstTime, setIsFirstTime] = useIsFirstTime();45if (isFirstTime) {6 return <Onboarding onComplete={() => setIsFirstTime(false)} />;7}
useSelectedTheme
Manages the user's explicit theme preference (light, dark, or system). It persists the choice and updates the native appearance.
1import { useSelectedTheme } from "@/hooks";23const { selectedTheme, setSelectedTheme } = useSelectedTheme();45// Switch to dark mode6setSelectedTheme("dark");78// Reset to system default9setSelectedTheme("system");
useTheme
Returns the active React Navigation theme object based on the current configuration. It resolves the conflict between system settings and user preference.
1import { useTheme } from "@/hooks";2import { NavigationContainer } from "@react-navigation/native";34export default function RootNavigator() {5 const theme = useTheme();67 return (8 <NavigationContainer theme={theme}>9 {/* ... */}10 </NavigationContainer>11 );12}
Last updated on 2/10/2026
Edit this page on GitHub