#91SensorsEasy

useOrientation

useOrientation

React sensor hook that tracks screen orientation of user's device.

Returns state in the following shape

{
  angle: 0,
  type: 'landscape-primary'
}

Usage

import {useOrientation} from 'react-use';

const Demo = () => {
  const state = useOrientation();

  return (
    <pre>
      {JSON.stringify(state, null, 2)}
    </pre>
  );
};
// TODO: implement useOrientation
function notImplemented(..._args: any[]): any {
  throw new Error('Not implemented');
}
export default notImplemented;
export const useOrientation = notImplemented;

Open browser consoleTests