Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

auto load window on change viewport react

import React from 'react'
function MyComponent() {
  const [dimensions, setDimensions] = React.useState({ 
    height: window.innerHeight,
    width: window.innerWidth
  })
  React.useEffect(() => {
    function handleResize() {
      setDimensions({
        height: window.innerHeight,
        width: window.innerWidth
      })
    
}

    window.addEventListener('resize', handleResize)

    return _ => {
      window.removeEventListener('resize', handleResize)
    
}
  })
  return <div>Rendered at {dimensions.width} x {dimensions.height}</div>
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular file upload code anji 
Javascript :: file path to blob javascript 
Javascript :: clear an array 
Javascript :: document.getelementbyid add number 
Javascript :: screen orientation and width&height 
Javascript :: How to Check if an Item is in an Array in JavaScript Using Array.includes() Starting From a Specified Index 
Javascript :: How to fix prettier messing up your HTML on save 
Javascript :: remove parent element jquery 
Javascript :: convert string to number 
Javascript :: how to scroll element in javascript 
Javascript :: convert milliseconds to dd/mm/yyyy javascript 
Javascript :: convert jquery to javascript converter online tool 
Javascript :: mongoose query document 
Javascript :: moment add 
Javascript :: ~~ in js 
Javascript :: javascript add css class 
Javascript :: javascript buffer to file 
Javascript :: how to focus out of an input in testing library 
Javascript :: Run FEnvQueryRequest 
Javascript :: Jenkins parse json keep order 
Javascript :: JavaScript for loop Display a Text Five Times 
Javascript :: navlink react active class 
Javascript :: intervals 
Javascript :: status role discord.js 
Javascript :: jquery if each checkbox is checked push array using each site:stackoverflow.com 
Javascript :: javascipt 
Javascript :: reactjs libphonenumber 
Javascript :: phaser mixed animation 
Javascript :: toast plugin 
Javascript :: string variable 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =