* usage
const usefadeIn = () => {
const element = useRef();
useEffect(() => {
// element 안으로 들어가기 위해서 useEffect 사용
if (element.current) {
const { current } = element;
current.style.transition = `opacity 1s`;
current.style.opacity = 1;
}
}, []);
return { ref: element, style: { opacity: 0 } };
};
const App = () => {
const fadeInH1 = usefadeIn();
return (
<div className="App">
<h1 {...fadeInH1}> Hello </h1>
</div>
);
};
@ggns/use-fade-in
1.0.1 • Public • PublishedPackage Sidebar
Install
npm i @ggns/use-fade-in
Repository
Weekly Downloads
1
Version
1.0.1
License
MIT
Unpacked Size
2.37 kB
Total Files
4