Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 370 Bytes

useOrientation.md

File metadata and controls

29 lines (21 loc) · 370 Bytes

useOrientation

React 传感器钩子,跟踪用户设备的屏幕方向。

以以下形式返回状态:

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

用法

import {useOrientation} from 'react-use';

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

  return (
    <pre>
      {JSON.stringify(state, null, 2)}
    </pre>
  );
};