Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

useWidthSize

const [width, setWidth] = React.useState(widthBrowser);

  const updateWidthAndHeight = () => {
    setWidth(window.innerWidth);
  };

  React.useEffect(() => {
    window.addEventListener("resize", updateWidthAndHeight);
    return () => window.removeEventListener("resize", updateWidthAndHeight);
  });

  console.log(width);
 
PREVIOUS NEXT
Tagged: #useWidthSize
ADD COMMENT
Topic
Name
1+2 =