react-gsap-hook
v0.0.3
Published
## Usage ##### _One line of code worths thousands lines of explanations._
Downloads
1,895
Maintainers
Readme
React GSAP Hook
Usage
One line of code worths thousands lines of explanations.
import React, { useEffect, useRef, useState } from "react";
import { useReactGsap } from "react-gsap-hook";
import styles from "./styles.module.scss";
const TEST_ANIMATION_CLASS_NAME = "test-animation";
const Container: React.FC<any> = () => {
const [show, setShow] = useState(false)
const containerRef = useRef(null);
useReactGsap(
show,
TEST_ANIMATION_CLASS_NAME,
{ opacity: 0, y: 20, duration: 0.38 },
{ opacity: 1, y: 0, duration: 0.38 },
);
useEffect(() => {
const intervalId = setInterval(() => {
setShow((prev) => !prev)
}, 1000);
return () => clearInterval(intervalId);
}, []);
return (
<div className={styles.container} ref={containerRef}>
<div className={`${styles.test} ${TEST_ANIMATION_CLASS_NAME}`}>test</div>
</div>
);
};
export default Container;
Development
- Git clone the project
https://github.com/duc168/react-gsap-hook.git
- Install lerna globally if you have not installed lerna yet, run
yarn global add lerna
- Run
npm install
to install the first packages npm start
to start developingnpm run stop
to stop developingnpm run build
to build a new version