skip to Main Content

Javascript – Why will this code allow for an update of the window width and height when clearly the event listener is removed within the same render cycle?

import React, { useState, useEffect } from 'react'; const WindowSize = () => { // Add your state and useEffect logic here const [windowWidth, setWindowWidth] = useState(window.innerWidth); const [windowHeight, setWindowHeight] = useState(window.innerHeight); const onResize = () => { console.log("resize detected");…

VIEW QUESTION
Back To Top
Search