### Install @react-native-community/hooks Source: https://github.com/react-native-community/hooks/blob/main/README.md Instructions for installing the library using npm or yarn. ```sh npm install @react-native-community/hooks ``` ```sh yarn add @react-native-community/hooks ``` -------------------------------- ### useAppState Hook Source: https://github.com/react-native-community/hooks/blob/main/README.md Hook to get the current application state, which can be 'active', 'background', or 'inactive'. ```javascript import {useAppState} from '@react-native-community/hooks' const currentAppState = useAppState() ``` -------------------------------- ### useDeviceOrientation Hook Source: https://github.com/react-native-community/hooks/blob/main/README.md Hook to get the current device orientation. ```javascript import {useDeviceOrientation} from '@react-native-community/hooks' const orientation = useDeviceOrientation() console.log('orientation is:', orientation) ``` -------------------------------- ### useImageDimensions Hook Source: https://github.com/react-native-community/hooks/blob/main/README.md Hook to get the dimensions (width, height, aspectRatio) of an image. Handles loading and error states. ```javascript import {useImageDimensions} from '@react-native-community/hooks' const source = require('./assets/yourImage.png') // or const source = {uri: 'https://your.image.URI'} const {dimensions, loading, error} = useImageDimensions(source) if (loading || error || !dimensions) { return null } const {width, height, aspectRatio} = dimensions ``` -------------------------------- ### useKeyboard Hook Source: https://github.com/react-native-community/hooks/blob/main/README.md Hook to track the keyboard's visibility and height. ```javascript import {useKeyboard} from '@react-native-community/hooks' const keyboard = useKeyboard() console.log('keyboard isKeyboardShow: ', keyboard.keyboardShown) console.log('keyboard keyboardHeight: ', keyboard.keyboardHeight) ``` -------------------------------- ### useAccessibilityInfo Hook Source: https://github.com/react-native-community/hooks/blob/main/README.md Hook to access accessibility information like bold text, screen reader, and reduce motion settings. Requires RN60+ for some properties. ```javascript import {useAccessibilityInfo} from '@react-native-community/hooks' const { boldTextEnabled, screenReaderEnabled, reduceMotionEnabled, // requires RN60 or newer grayscaleEnabled, // requires RN60 or newer invertColorsEnabled, // requires RN60 or newer reduceTransparencyEnabled, // requires RN60 or newer } = useAccessibilityInfo() ``` -------------------------------- ### useBackHandler Hook Source: https://github.com/react-native-community/hooks/blob/main/README.md Hook to handle the device's back button press. Allows custom logic or default behavior. ```javascript import {useBackHandler} from '@react-native-community/hooks' useBackHandler(() => { if (shouldBeHandledHere) { // handle it return true } // let the default thing happen return false },[shouldBeHandledHere]) ``` -------------------------------- ### useRefresh Hook Source: https://github.com/react-native-community/hooks/blob/main/README.md Hook to implement pull-to-refresh functionality, managing the refreshing state and callback. ```javascript import {useRefresh} from '@react-native-community/hooks' const fetch = () => { return new Promise((resolve) => setTimeout(resolve, 500)) } const {isRefreshing, onRefresh} = useRefresh(fetch) } /> ``` -------------------------------- ### useLayout Hook Source: https://github.com/react-native-community/hooks/blob/main/README.md Hook to measure the layout of a component after it has been rendered. ```javascript import { useLayout } from '@react-native-community/hooks' const { onLayout, ...layout } = useLayout() console.log('layout: ', layout) ``` -------------------------------- ### useInteractionManager Hook Source: https://github.com/react-native-community/hooks/blob/main/README.md Hook to defer tasks until after interactions and animations are complete. ```javascript import {useInteractionManager} from '@react-native-community/hooks' const interactionReady = useInteractionManager() console.log('interaction ready: ', interactionReady) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.