@prasiddha/react-window-size provides with a useWindowSize hook.
Use the package manager npm to install react-simple-spoiler.
npm install @prasiddha/react-window-size --save
import { useWindowSize } from '@prasiddha/react-window-size';
const App = () => {
const { width, height } = useWindowSize();
return (
<div
style={{
height: '100vh',
width: '100vw',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<div>
<h1>Height:{height}</h1>
<h1>Width:{width}</h1>
</div>
</div>
);
};
export default App;
export default App;
--
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.