3. Detecting Orientation Changes #
Created Wed Nov 15, 2023 at 3:30 AM
To detect realtime orientation of the device, a hook useDeviceOrientation
is available.
Steps to use:
npm install @react-native-community/hooks
- Code
import { useDeviceOrientation } from '@/react-native-community/hooks'; function MyComponent() { const orientationValue = useDeviceOrientation(); // 'portrait' | 'landscape' return null; }