react js get screen size

Solutions on MaxInterview for react js get screen size by the best coders in the world

showing results for - "react js get screen size"
Julian
14 May 2017
1// useWindowDimensions.js
2
3import { useState, useEffect } from 'react';
4
5export default function useWindowDimensions() {
6
7  const hasWindow = typeof window !== 'undefined';
8
9  function getWindowDimensions() {
10    const width = hasWindow ? window.innerWidth : null;
11    const height = hasWindow ? window.innerHeight : null;
12    return {
13      width,
14      height,
15    };
16  }
17
18  const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
19
20  useEffect(() => {
21    if (hasWindow) {
22      function handleResize() {
23        setWindowDimensions(getWindowDimensions());
24      }
25
26      window.addEventListener('resize', handleResize);
27      return () => window.removeEventListener('resize', handleResize);
28    }
29  }, [hasWindow]);
30
31  return windowDimensions;
32}
33
34// yourComponent.js
35
36import useWindowDimensions from './hooks/useWindowDimensions';
37
38const Component = () => {
39  const { height, width } = useWindowDimensions();
40  /* you can also use default values or alias to use only one prop: */
41  // const { height: windowHeight = 480 } useWindowDimensions();
42
43  return (
44    <div>
45      width: {width} ~ height: {height}
46    </div>
47  );
Maya
10 Jan 2019
1import { useState, useEffect } from 'react';
2
3function getWindowDimensions() {
4  const { innerWidth: width, innerHeight: height } = window;
5  return {
6    width,
7    height
8  };
9}
10
11export default function useWindowDimensions() {
12  const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
13
14  useEffect(() => {
15    function handleResize() {
16      setWindowDimensions(getWindowDimensions());
17    }
18
19    window.addEventListener('resize', handleResize);
20    return () => window.removeEventListener('resize', handleResize);
21  }, []);
22
23  return windowDimensions;
24}
Estelle
03 Sep 2018
1  console.log(window.innerHeight);
2
queries leading to this page
get screen size react mediumreact get window widthwindow width react stylehave size screen in reactreact realtime screen widthget screen width and height reactget screen width using react jsreact js get screen resolutionreact js detect screen sizereact check screen sizereact get screen widthreact screen size conditionreactjs detect mobile sizeget screen size using reactreactjs detect screen sizereactjs show component if screen sizecheck screen size reactwindow innerwidth in reacthow to get the width of my screen in reactreact js css get screen resolutionreact get window sizereact get window heightget width of screen reactkeep track of screen size in reacthow to get starting element of screen height in reactuse screen width in reacthow to get current window widtrh in react jshow to get the heigth and the width of my window in reactreact how to know the screen widthget page width reacthow to calculate width screen in reactjsget current screen size react mediumhow to get width of screen in react native class componentreact get height and width of screencheck screen size and set state in reactreact screen width sizehow to get the screen size in reactcheck size screen reacthow to get width of screen in react in class componenthow do detect screen size in reactfull width of screen react jswidth of screen react screen width reactahow to get the width of the screen in reacgchange component with width of screen reacthow to find the width of screen in react jshow to check screen width in reactcheck width of screen reacthow to get screen height in reactget size of screen reacthow to find screen width in reactjsreact js get screen width and heightwidth and height of screen reactwatch screen size reactscreen size if react jsreact how to check screen widthhow to check the size of the screen in reacthow to get screen width and height in react nativrwidth screen reacthow to get the width of screen in javascript reactcheck screensize reacthow to get a window screen size in reactreact screen widthshow to get the current width of screen in reactreact how to determine how big browser size is 2c not screen sizedetermine components screen size reacthow to render elements acc to screen size in reactreact always check screen sizereact track screen resizeshow component based on screen sizereact detect screen size changeget users width of screen window react jsget current screen size react jsview to take whole width of screen react nativwscreen size detect in recathow to find screen width in reactreact device widthfind out screen size reactreact screen sizeshow to get screen dimensions in reacthow do i find the screen size of the user in reactscreen size react jsreactjs find the width of the screenhow to check the screen width in reactget resolution of screen in react jsget the width of screen reactfull screen width in reactsize component based on screensize reactheight same like window reactget width of screen in reacthow to get width of screen in javascript react jshow can i show component as for screen size in reactget screen width reactjswindow width reactget window size reactreact getscreenwidthreact calculate width divacenpm to get screen size in reacthow to check screen size in reacthow to check view width in react 2f jsreact check if screen sizereactjs adjust screen for mobielhow to find the width of the screen in reacthow to use screen width in reactjsread screen size in react functional componentverticallydivide two section based on window height using reactreact detect screen resizehow to get width of screen in react class componentreact change viewportreacts screen widthwindow width in reactdetect screen width reactreact scroll widthreactjs detect screen resolutionscreen size reactscreen width in react jsinitiate js code after browser size reached reactjshow to get input width reactcheck screen resolution reacthow to get width screen in reactjsget device screen width reactreact get width of screenhow to detect screen size with react responsivedetect device size reactdetect width in reactreact check if small screen sizedetect screen size reactjsreact js screen widthreactjs width base on screen sizescreen width reacthow to get window size i jsxdata in react if screen sizereact get with of screenreact screen sizeset width to whole screen reactjsreact get sceen widthhow to find screen size using reactjsreact screen size detectget screen width reactjs hokksdetect screen size change in reactwindow height using reactinnerhight reactreact js get screen sizehow to get the client screen width reactreact js use screen sizefind screen size react mobileget screen size in reactjsreact do something when screen size changesreact how to get get window witdth sizereact change component based on screen sizeget screen size reactjsgetting the screen size in reactget screen size js reactreact component based screen sizeget width of screen in component reactreact check screen size on rendercheck screen size in reactaccess screen width reactreact check small screen sizereact js detect full screen sizeshow element in react js based on screen sizeget resolution of screen reactreact height size of browser heightshow react component based on screen sizeget page height in reacthow to screen width in reactdetect width of screen reacthow to change component size based on screen size reactwindow not getting all height reactjsscreen size with react statehow to get screen width in react jshow to get component starting screen height in reacthow to get the width of the screen in reacthow to get screen size in typescript react jsreact width of screenscrren width in reactreact js get window heighthow to get the browser viewport dimensions reactscreen width in reactget sreen width react jsreactjs get screen sizereact widthreact return based on screen sizescreen width react jsreact detect screen width changehow to get the screen width in javascript reactreact detect screen sizezhow to use screen width for js in reactscreen width detection reactreact check size of screenreact detect window sizereact screen widthhow to get screen size in reactget window width reactdetect screen size reactreact js get screen widthdetect screen size on load reactcheck screen width reathow to find screen size in reacthow to get page width in reactreact how to get widthof screenget window width in reactreact client widthreact get current viewport sizeget screen size with reactreact js get screen sizereact if screen widthreact component screen sizehow to keep track on screen width in reacthow to read the screen size in reacthow to check screen size from js in reactreact native how to detect screen widthget screen size html jss reactreact client screen widthcheck screen width of cmponent reacthow to track screen size in reactreact check if screen size changedreact width based on screen widthhow to reading screen size in react jsget the screen width reactscreen resolution sizes in reacthow to get screen width in jsxreact get current screen sizescreen size using javascript reacthow to check screen size inside jsxscreen width reactjshow to make the screen work in different sizes reactget screen size react how to get the screen size by react packagereact render based on screen sizejs size of screen reacthow to get height and width of screen in react js in cssget screensize values on prop in reactreact typescript get window heightusing javascript find width of screen in reacthow can get screen size reactreact js screen heighthow to read screen width on reactget screen dimensions in reactdetect window size in reactget size screen in reactjsusing react to detect different screen sizesreact get size of screenwindow screen width in react class componenthow to find screen width and height in reactjshow to get the screen height in react jsget screen width and height in reactshow item window width reactget window dimensions reacthow to access the viewport in reactreact innerhieghthow to check current screen width in reactmake react component size of screenreact detect screen sizerender using screen size in reacthow to check screen width in reactjschange screen width reactreact how to get view widthreact check width of screenwindow screen width in reactget display size react jsget screen width react js first renderreact detect small screenjavascript detect change screen size reacthalf of window innerhight reactdetect screen size in reactget the current device width reactwindow innerheight inreactget size screen in class reactjs get screen width in reactreact js get screen dimensionsreact js use screen size class componentjsx screen sizehow can we get the height and width of the screen in reactreact get window width and heightwindow width in reactjshow to get screen size reactreact grab page widthhow to check for screen size in reactreact window widthreact access screen widthcan i detect screen size in react componentreact detect screen widthhow to get screen width in reactreact get width screenreact how to get screen widthhow to get screen size in reactjsreactjs get width of screenreact change render on screen sizereact window screen widthreactjs how to set heght acording to screen in reactjsquerry screen sizes reacthow to get screen width in reactjsreact js use screen sizereact get page widthhow to check size of screen in reactreact get screen size mediaget width screen reactscreenn with usign js in reactget screen size in reactdetect screen size change reactjsreact full screen widthhow to get size of screen in reactreact window innerwidthget screen height reactget screen dimensions reactreactjs window heightcheck screen width reactreactjs screen widthhow to detect screen width react javascripthow to get screen width in react in cssreact get screen resolutionhow to check screen size and set classes in reactjavascript get window width reacthow to detect screen size change in reactreact use screen sizereact window heighthow to change react component size based on screenreact get scrren sizereact set screen sizereact get current widthreact get screen widthfunction that keeps checking screen size in reactreact css get screen resolutionhow to get dimension of screen in react jsavailable screen width react jsreact how to get width of screenhow to use window screen width in reactreact how to determine user screen sizehow to detect screen size in reactreact works in al screen sizedocomrnt object for screen width react react window width heightget screen size using reacreact how to know the size of screenget width screen reactjsget current screen size reactreact get page height on how to detect the change of screen size of the device using react jsfind screen width reacthow to get the screen width of the dom in react jshow to handle different screen size in react jsreact get device widthreact get screen sizereact current screen widthdetecting a innerwidth reactwindow width reactget display size in reactfix screen width view reactjsget width page in react jsreact determine screen sizereact get current window widthhow to check for screen size with reactreact get current screen widthhow to check browser resolution in reactreact how to check if screen size changehow to get screen size in react every time it changesget current screen width reactwindow react figure out screen size on loadhow to get screen size in react jsusing screen width in reactreactjs screen dimensionsreact get screen width while resizing screenreact to validate width of the devicereact get screen heightwindow screen width reactget screen width react jscalculate screen size reacthot to get screen width in reacthow to check resize screen in reacthot to get screen size in reactreact change size of screencheck screen width react renderhow to check screen width change in reactget the sizr of the screen in reactreact window screen widthget screen resolution reactget screen height width react natieshow element based on screen size reactget screen width reactreact js to check screensizehow to know the width of the window in reacthow to get screensize reacthow to render component based on screen size reactfind width screen react javascriptreact page heightget height of window reactscreen size in reactget screen size as state reacthow to find broser width reatjsscreen size detector reacthow to get width of screen in reactreact detect width of screenhow to get the screen size by reactreactjs get device heightreact get resolution screenreact check screen widthget the screen width in reactchecking screen size in reactjscheck device width reactjshow to get screen height in reactjsreact js get screen width of elementnpm get screen height in reactjsscreen size change detector in reactreact getting the width of the screenreact native detect screen sizereact functional components detect screen sizeaccess document screen width reactscreen height reactreactjs get screen hightfinding screen width in reactdetect screen size react jsreact use screen dimensionshow to change screen size in react appreactjs get height of screenwindows screen size reactjsget screensize values on prop in react js in class componenthow to get the screen size in pixels reactjsreact js get screen size