useLifeCycle
Introduction
Example
import React from "react";
function ExampleComponent() {
// 컴포넌트가 마운트될 때 실행될 작업
const onMount = () => {
console.log('Component is mounted!');
};
// 컴포넌트가 언마운트될 때 실행될 작업
const onUnmount = () => {
console.log('Component is unmounted!');
};
// useLifeCycle 훅을 사용하여 라이프사이클 이벤트에 대응하는 작업 설정
useLifeCycle(onMount, onUnmount);
return (
<div>
{/* 컴포넌트의 내용 */}
</div>
);
}Hook
Last updated