Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 320 Bytes

useWindowSize.md

File metadata and controls

21 lines (15 loc) · 320 Bytes

useWindowSize

React 传感器钩子,用于跟踪浏览器窗口的大小。

用法

import {useWindowSize} from 'react-use';

const Demo = () => {
  const {width, height} = useWindowSize();

  return (
    <div>
      <div>width: {width}</div>
      <div>height: {height}</div>
    </div>
  );
};