Skip to content

bence-toth/react-hook-screen-orientation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-hook-screen-orientation 🔃

A React hook for detecting screen orientation.

Installation

Using npm:

npm install --save react-hook-screen-orientation

Using yarn:

yarn add react-hook-screen-orientation

Usage

import React from 'react'
import useScreenOrientation from 'react-hook-screen-orientation'

const ComponentWithScreenOrientation = () => {
  const screenOrientation = useScreenOrientation()

  return (
    <p>Screen orientation is: {screenOrientation}</p>
  )
}

Notes

The screenOrientation value provided by the hook is the type propery of a ScreenOrientation interface is always one of the following strings:

  • portrait-primary
  • portrait-secondary (meaning upside down)
  • landscape-primary
  • landscape-secondary (meaning upside down)

Contributions

Contributions are welcome. File bug reports, create pull requests, feel free to reach out at [email protected].

Licence

LGPL-3.0