showing results for - "react get screen width"
Jerónimo
05 Feb 2020
1const Component = () => {
2  const { height, width } = useWindowDimensions();
3
4  return (
5    <div>
6      width: {width} ~ height: {height}
7    </div>
8  );
9}
10
Abril
12 Jun 2016
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  );
Noan
13 Nov 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}
Julia
02 Nov 2020
1  console.log(window.innerHeight);
2
Ela
15 Oct 2019
1class Main extends React.Component {
2 constructor(props) {
3    super(props);
4    this.state = { windowWidth: window.innerWidth };
5  }
6
7 const handleResize = (e) => {
8  this.setState({ windowWidth: window.innerWidth });
9 };
10
11 componentDidMount() {
12  window.addEventListener("resize", this.handleResize);
13 }
14
15 componentWillUnMount() {
16  window.addEventListener("resize", this.handleResize);
17 } 
18
19  render() {
20    const { windowWidth } = this.state; 
21    return <div>Current window width: {windowWidth}</div>
22  }
23}
queries leading to this page
check for window size in reactreact innerheightgetting the screen size in reacthow to get the screen height in react jsview to take whole width of screen react nativwreact js on window sizehow to get the width of the screen in reacthow can we get the height and width of the screen in reactreact how to know the size of screenget screen width react jsget window size reactshow component based on screen sizereact detect screen resizehow to get the size of the window reactreact get window width and heighthow can get screen size reactscreen size with react statewindow width react stylereact determine screen sizereact check window sizereactjs screen dimensionshow do detect screen size in reacthow to check view width in react 2f jsget window dimensions react jshow to check current screen width in reactnpm to get screen size in reactreact js get screen sizescreenn with usign js in reactreact get screen width while resizing screenhow to get screen size in typescript react jshow to get screen width and height in react nativrhow to find screen width and height in reactjshow to get the value of window width in reactaccess screen width reactwindow size in react jsreact how to check if screen size changedetermine components screen size reacthow to get width of screen in react native class componentreact current screen widthreact show browser widthreact viewport heightreact change size of screencheck screen width reacthow to get screen height in reacthow to make the screen work in different sizes reactget size of screen reactcheck screen size reactreact window width heightreact how to get screen widthfunction that keeps checking screen size in reactdetect screen size change reactjsget screen size react mediumhow to track screen size in reacthow to check resize screen in reacthow to get starting element of screen height in reactreact getting the width of the screenhow to get the width of my screen in reactreact check size of screenreact change viewportscreen size react jsreact get screen widthreact window innerwidthhow to watch window width in reactreact js use screen sizereact js get screen sizereact device widthreact js use screen size class componentfind out screen size reactgetting window dimensions reactwatch screen size reactreact screen width sizereactjs get window widthget window size with react hhoksreact how to determine user screen sizehow to detect the change of screen size of the device using react jshow to calculate width screen in reactjsreact realtime screen widthhow to get the width of the window in react classhow to check screen size from js in reacthow to get width of window in reactdetect screen size reactscreen width detection reacthow do i find the screen size of the user in reactscreen size change detector in reactreact how to get view widthhow to get the size of the window in react classreact get current window heightsize component based on screensize reacthow to find the width of the screen in reacthow to check window width in react jsreact how to know the screen widthcheck window width reacthow to make window width size small reactreact js get screen width and heighttarget window width in react jshow to render elements acc to screen size in reactreact get screen heightscrren width in reactget window size in reactreact get height and width of screenget screen size js reactreact get windows sizehow to check for screen size with reactreact check screen size on renderreact window sizewindow height js reactjsreact screen size detectjs get window width reactget screen dimensions in reactget width of screen reacthow to get the screen width in javascript reactget screen height width react natieget width of the window in reactget current screen size reactheight same like window reactreact get size of screenhow to check screen size in reactget screen size html jss reactdetect window width reactreact client screen widthreact get window height and widthget device screen width reactget height of window reacthow to get the value of window width in react for responsivehow to get screen width in reactwindow width reacthow to use window screen width in reactcalculate screen size reactreactjs get screen hightreact widthset window size reacthow to find the width of the window in reactreact use screen dimensionsget window dimensions reactreact check window current sizereact get device widthhow to get the screen size by reactreact component screen sizehow to get input width reactreactjs show component if screen sizehow to make my page fit in the current window react jsget resolution of screen reactmange window size in reactget window height and width javascript in reactreact set screen sizeusing react to detect different screen sizesjsx screen sizehow to get window width on resizable in react jsget screen size as state reactwindow size reactreact check screen widthreact screen widthwindow innerwidth in reacthow to change window size reactwindow innerheight react jsclg my window size in reactget width windowa reactreactjs get screen sizeget the screen width reactgetting width of window in reactget screensize values on prop in react js in class componentreact check screen sizereact get current viewport sizedetect screen size reactjsreact get screen size mediareact js get window widthhow to get the client screen width reactset window width reacthow to get the width of the window in reactchange component with width of screen reactreact detect window width componentwindow screen width in reactreact window screen widthreact dom get windowget current screen size react mediumjavascript detect change screen size reacthow to screen width in reactreactjs width base on screen sizereactjs get height of screenhow to use screen width in reactjshow to get a window screen size in reactreact get with of screenhow to get width of window reactget page width reacthow to set window width of html reactjsreact how to get width of screenreact screen widthshow to add window size in reactget screen size in reacthow to change screen size in react apphow to get screensize reactcan i detect screen size in react componentget width of window reacthow to know the width of the window in reactreact get width of window class componentget the width of screen reactfind width screen react javascriptreact use screen sizehow to calculate window size in reactreact get current window widthwidth screen reactreact window screen widthreact get sceen widthreactjs return window sizehow to access the viewport in reactreact js get screen widthhow to get page width in reactget current screen size react jshow to get total window size in reactuse screen width in reactwindow width reacthow to get width of window without reacthow to set window width reactget width of screen in component reactreact if window widthdetect screen size change in reactreact native detect screen sizefull screen width in reacthow to use screen width for js in reacthow to change window screen size in reactreact native how to detect screen widthhow to get width of screen in reactreact typescript get window heighthow to keep track on screen width in reactreact client widthverticallydivide two section based on window height using reactreact get window sizesreact if screen widthget dimension react screenget screen height reactshow item window width reactreact to validate width of the devicehow to reading screen size in react jshalf of window innerhight reactreact js get screen resolutionreact get current widthhow to get size of screen in reactreact js to check screensizereact window client heightuse window size reacthow to check browser resolution in reactreact get page height on detect device size reactreact window dimensionsdetect window size in reactget width of screen in reactset width to thhe complete window size reactreact window heighthow to read screen width on reactreact screen sizeshow to get the window width in react jshow to get screen size in react jsfull width of screen react jsreact js css get screen resolutionget current window width reactreact check if small screen sizereactjs window heightreact detect width of screenwidth of screen react react js use screen sizereact js detect full screen sizeget display size react jscheck screen resolution reactget window width in react jsreact get current screen sizescreen size detect in recatinitiate js code after browser size reached reactjsreact height size of browser heighthow to read the screen size in reactreact functional components detect screen sizewindow dimensions react jsget window width react js 5creactjs screen widthhow to find broser width reatjsreact render based on screen sizereact get window width dprdetect width in reactnpm get screen height in reactjshow to get screen size in reacthow can i show component as for screen size in reacthow to set window size in react jsshow element in react js based on screen sizehow to change react component size based on screenhow ot check window width in reactwhy is the window so wide in my react app 3fhow to check screen width in reactjscheck device width reactjscheck in react window widthreact width of screenreact js get window heightreact change component based on screen sizereact get current screen widthget screen resolution reactquerry screen sizes reactreact page heighthow to get dimension of screen in react jsreact js detect screen sizehow to get current window widtrh in react jshow to get the width of window in reactget sreen width react jsget display size in reactgetting the window size in reactcheck window size javascript reactget screen width reactjshow to get window width in reactget screen size with reactscreen width reactjsusing javascript find width of screen in reactdetect current window size in reactget width screen reactreactjs check width of windowreact js screen heightreact width based on screen widthscreen size in reactscreen height reactreactjs get width of screenhow to get the width of the screen in reacgreact how to get window px widthreact how to check screen widthreact get window width on resizereact how to determine how big browser size is 2c not screen sizeget screen size using reactscreen size reactreact window how to calculate item sizereact get width screenhow to check screen width in reactwindows screen size reactjshow to get the window width in reactreact do something when screen size changesreact check width of screenhow to get the screen size in pixels reactjsreact get width of windowreact get screen sizehow to get window width in reactjsscreen width reactaget size screen in class reactjs how to check screen size inside jsxget screen size reactjsget screen width reactjs hokksrender using screen size in reactscreen size detector reactcheck window width in react get screen width using react jshow to detect screen size change in reacthow to get the width of screen in javascript reactget the screen width in reactreact how to get widthof screenget screen width and height in reactcheck screen width react renderhow to get current window size in react jsreact js if window sizehow to render component based on screen size reactfind screen width reacthow to get width of screen in javascript react jshow to know the size of window in reactreact get scrren sizehow to get the current window width in reactkeep track of screen size in reactfinding screen width in reactread screen size in react functional componenthow to get window width reactreact window widthscreen size if react jswidth and height of screen reactwindow size jsx getreactjs calculate window width in classhow to get windows size in react jsreact window heightreact grab window widthwindow innerheight inreacthow to check screen width change in reactget screen size in reactjsjavascript get window width reactget screen dimensions reactaccess document screen width reacthow to get width screen in reactjsinnerhight reactcalculate window size reactdetect width of screen reactget width of window in reactjshave size screen in reacthow to get window size reactget screensize values on prop in react jshow to access window width in reactreact check if screen sizereact how to get window height 2c widthreact detect screen size changehow to get window size in reactjs size of screen reactfunction component react get window sizeget width page in react jsreact get window dimensionshow to check window width reactreact screen sizehow to find screen size using reactjsdetect screen size in reacthow to detect screen size in reactget current width of browser window reactwindow screen width in react class componentshow react component based on screen sizedetecting a innerwidth reactheight same like window react 2020window not getting all height reactjshow to make window width of the application in reactgetting size of window in reacthow to get the browser viewport dimensions reactreact detect screen width changehow we will get current window size in react jsset width to whole screen reactjshow to get window dimenions on reactreact getscreenwidthget resolution of screen in react jsget width of browser window reactget screensize in reactgetting window size in react jshow to get width of screen in react class componenthow to change component size based on screen size reactdetect screen width reactreact js get screen dimensionsreact get resolution screenhow to check the screen width in reactget windows size javascript reactchange screen width reactreactjs detect mobile sizehow to get the width of a window in reactcheck screensize reactdetect screen size react jsreact check small screen sizecheck screen size and set state in reacthow to check the size of a window in reacthow to check dimension window in reactdetect screen size on load reactreact calculate width divacehow to get screen width in reactjsscreen size using javascript reacthow to get the screen size in reactfind screen size react mobilehow to get screen size reactget the window size on resize reactreact detect screen sizezhow to find the width of screen in react jswindow size 3e 3d700 reactget width screen reactjsreactjs get device heighthow to find screen width in reactjshow to check size of screen in reacthow to check for screen size in reacthow to find screen size in reacthow to get the current width of screen in reactcheck screen width reathow to c heckout window width size in reacthow to get width of screen in react in class componenthow to get the screen width of the dom in react jsget screen size using reacreact update window sizeset window width react new windowreact get page widthhow to get screen width in jsxget window width react in pxshow element based on screen size reactreact window sizehow to detect screen width react javascriptacces window width reactget div width on window resize reactjsreact detect screen widthget window width on resize reactreact screen size conditionget window width when resize reacthow to define window size in reactmanually set window size reactget window size react site 3apinterest 2areact check window widthreactjs adjust screen for mobielwindow dimensions in reactdocomrnt object for screen width react data in react if screen sizereactjs find the width of the screenget size of window reactreact js screen widthscreen width in react jshot to get screen size in reacthow to get window height in jsxreact how to get get window witdth sizereact innerhieghtreactjs detect screen resolutionget screen width reacthow to get screen width in react jsget window width in reactget screen width in reactwindow width in reactjsscreen width react jsavailable screen width react jshow to check window width reacthow to know the width of the current window in reacthot to get screen width in reactscreen resolution sizes in reactreact css get screen resolutionreact get window widthusing screen width in reacthwo to monitor window size in reactjsscreen dimension reactreact component based screen sizewindow screen width reactreact get screen widthget window width reacthow to get screen dimensions in reactget page height in reactget screen size react fix screen width view reactjsreactjs detect screen sizereacts screen widthreact get screen resolutionreact get width of screenreact change render on screen sizereact grab page widthreact window heightcheck screen width of cmponent reacthow to get the heigth and the width of my window in reactreact js get screen width of elementmake react component size of screenhow to detect screen size with react responsivehow to get height and width of screen in react js in csschecking screen size in reactjshow to get window size in js reactcheck size screen reactreact return based on screen sizereact use window sizewindow react figure out screen size on loadhow to get window size i jsxreact check if screen size changedreact how to be full width of windowhow to get screen height in reactjsreact detect small screenreact always check screen sizehow to get screen width in react in cssget the sizr of the screen in reactreact detect window sizehtml read window size reacthow to detect window size in reactget window width react jsget current screen width reactwindow width in reacthow to get the screen size by react packagereact find window widthget size screen in reactjscheck screen size in reactreact access screen widthract get window sizereact detect screen sizecheck width of screen reactreact get window sizereact get size of windowhow to find window width in reactget screen width react js first renderhow to find screen width in reactwindow size in react appreact get window heightreact full screen widthhow to handle different screen size in react jsget users width of screen window react jshow to get screen size in reactjswindow size in reactwindow height using reactscreen width in reacthow to check the size of the screen in reacthow to check screen size and set classes in reactchange window size react how to get screen size in react every time it changesreact scroll widthget screen width and height reacthow to check window size in reacthow to know the browser window size reacthow to fix the heghit of website same as brosewr height in reactget current window width in reacthow to get component starting screen height in reactreact works in al screen sizereactjs how to set heght acording to screen in reactjsscreen width reactget screensize values on prop in reacthow to get window device width in reactjsget the current device width reactreact track screen resizereact get screen width