UNPKG

@react-hookz/web

Version:

React hooks done right, for browser and SSR.

11 lines (10 loc) 395 B
import { useMediaQuery } from '..'; /** * Checks if screen is in `portrait` or `landscape` orientation. * * As `Screen Orientation API` is still experimental and not supported by Safari, this * hook uses CSS3 `orientation` media-query to check screen orientation. */ export function useScreenOrientation() { return useMediaQuery('(orientation: portrait)') ? 'portrait' : 'landscape'; }