Created
May 21, 2020 16:53
-
-
Save alejovdev/e99e9eac1af92aad3bfe08b4222e15b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useLayoutEffect, useRef } from 'react' | |
function MyComponent() { | |
const [windowSize, _setWindowSize] = useState([0, 0]) | |
const windowSizeRef = useRef(windowSize) | |
const setWindowSize = (value) => { | |
windowSizeRef.current = value | |
_setWindowSize(value) | |
} | |
// Here we can normally use setWindowSize([x,y]) and windowSize | |
useLayoutEffect(() => { | |
function onWindowResize() {} | |
return () => {} | |
}, []) | |
return <div>Hi There</div> | |
} | |
export default MyComponent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment