stream-chat-react-native-core
Version:
The official React Native and Expo components for Stream Chat, a service for building chat applications
16 lines (13 loc) • 528 B
text/typescript
import { useWindowDimensions } from 'react-native';
export type ScreenOrientation = 'landscape' | 'portrait';
/**
* A custom hook that derives the current screen orientation from the window
* dimensions. It updates automatically on device rotation via
* `useWindowDimensions`.
*
* @returns {ScreenOrientation} Either `'landscape'` or `'portrait'`.
*/
export const useScreenOrientation = (): ScreenOrientation => {
const { height, width } = useWindowDimensions();
return width > height ? 'landscape' : 'portrait';
};