useLocation

February 26, 2019 · View on GitHub

React 传感器钩子,用于追踪浏览器的位置。

对于 Internet Explorer,你需要安装polyfill

用法

import {useLocation} from 'react-use';

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

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