What are hooks in React Native?
Answer
React Native uses the same React hooks as React web — they work identically. All standard hooks apply: useState: local component state: const [count, setCount] = useState(0);. useEffect: side effects — data fetching, subscriptions, cleanup. Runs after render: useEffect(() => { fetchData(); return () => { cleanup(); }; }, [dependency]);. useCallback: memoize a function — prevents unnecessary re-renders of child components that receive the function as a prop: const handlePress = useCallback(() => { doSomething(); }, [dependency]);. useMemo: memoize computed value: const expensiveValue = useMemo(() => computeExpensive(data), [data]);. useRef: access a component or store a mutable value without re-render: const inputRef = useRef(null); inputRef.current.focus();. useContext: access context value: const theme = useContext(ThemeContext);. useReducer: complex state logic: const [state, dispatch] = useReducer(reducer, initialState);. React Native-specific hooks (from libraries): useFocusEffect (React Navigation) — runs when screen is focused; useNavigation (React Navigation) — access navigation object anywhere; useSafeAreaInsets (react-native-safe-area-context) — get safe area insets for notch/home indicator; useColorScheme (built-in) — detect dark/light mode: const colorScheme = useColorScheme(); // "dark" | "light" | null. Custom hooks: same pattern as React web — extract reusable stateful logic into functions starting with "use".