"DOM이 생성되고 웹 브라우저상에 나타나는 것을 마운트(mount)라고 합니다.”
"사용자 화면에 뷰를 보여 주는 것을 렌더링이라고 합니다."
1.렌더링 할 때마다
useEffect(( ) => {
console.log('렌더링이 완료되었습니다!');
});
2.마운트 될 때만
useEffect(() => {
console.log('마운트될 때만 실행됩니다.');
}, []);
3.특정 값이 업데이트 될 때
useEffect(() => {
console.log(name);
}, [name]);
4.뒷정리(렌더링되고 난 직후)
useEffect(() => {
console.log('effect');
console.log(name);
return () => {
console.log('cleanup');
console.log(name);
};
});
5.언마운트 될 때만 뒷정리 함수
useEffect(() => {
console.log('effect');
console.log(name);
return () => {
console.log('cleanup');
console.log(name);
};
}, []);
'도서' 카테고리의 다른 글
러닝 자바스크립트 (0) | 2019.02.21 |
---|---|
최신 표준 HTML+CSS디자인 (0) | 2019.02.12 |
리눅스 마스터 2급 (0) | 2018.10.05 |
후니의 쉽게 쓴 시스코 네트워킹 (0) | 2018.09.23 |