@21kb/react-page-visible-hook 中文文档教程
@21kb/react-page-visible-hook
使用页面可见性 API
Install
npm
npm install --save @21kb/react-page-visible-hook
Yarn
yarn add @21kb/react-page-visible-hook
Usage
import useVisible from '@21kb/react-page-visible-hook';
// import App from './App';
// import Loader from './Loader';
const Component = () {
const state = useVisible();
const {visibilityState} = state;
return (
{visibilityState === 'prerender' ? <Loader /> : <App />}
);
};
License
MIT的 React 钩子
@21kb/react-page-visible-hook
React hook to use the Page Visibility API
Install
npm
npm install --save @21kb/react-page-visible-hook
Yarn
yarn add @21kb/react-page-visible-hook
Usage
import useVisible from '@21kb/react-page-visible-hook';
// import App from './App';
// import Loader from './Loader';
const Component = () {
const state = useVisible();
const {visibilityState} = state;
return (
{visibilityState === 'prerender' ? <Loader /> : <App />}
);
};
License
MIT