import { useState } from 'react'

import { useEventListener } from './useEventListener'

export const useScreenOrientation = () => {
  const [orientation, setOrientation] = useState(window.orientation)

  useEventListener({
    callback: (e) => setOrientation(window.orientation),
    event: 'orientationchange',
  })

  return orientation
}
