react detect screen size
import { useState, useEffect } from 'react';
function getWindowDimensions() {
const { innerWidth: width, innerHeight: height } = window;
return {
width,
height
};
}
export default function useWindowDimensions() {
const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
useEffect(() => {
function handleResize() {
setWindowDimensions(getWindowDimensions());
}
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
return windowDimensions;
} console.log(window.innerHeight);
Also in JavaScript:
- Material-ui aircon icon
- javascript base 10 to base 2
- encriptar exadecimal con cryptojs
- mongodb nodejs connect localhost
- javascript limit input to 2 decimal places
- javascript object get property or default
- semantic ui dropdown value
- nuxt js lazy load page pagination
- dispay react component after some time
- javascript on submit
- node send file
- router nextjs
- vuejs remove object from array
- react redirect after login
- reactjs limit text display 20 200 characters
- set variable with json javascript
- Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
- how to make a javascript game
- uninstall node js from mac
- component did mount mutation graphql
- javascript option
- capitalize in javascript
- compare two arrays
- js obj getting count of properties