Open Youngju-Jang opened 1 year ago
: useEffect를 사용한 후, 해당 컴포넌트가 없어질때 실행됨
function Hello() {
useEffect(() => {
console.log("Created :)");
return () => console.log("destroyed :(");
}, []);
return <h1>Hello</h1>;
}
function Hello() {
function effectFn() {
console.log("created :)");
return destroyedFn;
}
function destroyedFn() {
console.log("bye :(");
}
useEffect(effectFn, []);
return <h1>Hello</h1>;
}