목록2020/04/07 (1)
차근차근
[React Hooks] Hooks (2)
0. useEffect useEffect는 componentWillUnmount, componentDidMount, componentWillUpdate와 비슷하다. 이 모든 것과 동일한 function이다. react hooks로 작업할 때 중요하다. 다음 예시를 보자. useEffect는 ComponentDidMount, componentDidUpdate의 역할을 하기 때문에 시작하거나 버튼을 클릭할 때 콘솔에 hello가 찍힌다. useEffect의 첫번째 인자는 function으로서의 effect가 된다. 두번째 인자는 dependency이다. 만약 dependency(deps)가 있다면 effect는 (deps)리스트에 있는 값일 때만 값이 변하도록 활성화 될 것이다. 다음 dependency를 ..
대학교/FE
2020. 4. 7. 15:45