Last active
August 29, 2021 13:00
-
-
Save yeonwooz/9f67428ea3d9497d3479b99355acd78f to your computer and use it in GitHub Desktop.
useEffect_when_updating
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
// dependency array - 주시하는 state가 없을 때 | |
useEffect(() => { | |
logicForMounting() // 마운트, 리렌더링 될 때마다 실행 | |
return () => { | |
logicForUnmounting() // 언마운트될 때, 리렌더링 될 때마다 실행 | |
} | |
}) | |
// dependency array [ state ] - 주시하는 state가 있을 때 | |
useEffect(() => { | |
logicForMounting() // 마운트, 리렌더링 될 때마다, state 업데이트될 때마다 실행 | |
return () => { | |
logicForUnmounting() // 언마운트될 때, 리렌더링 될 때마다, state 업데이트될 때마다 실행 | |
} | |
}, [someState]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment