bring your componenets to life with simple spring animation primitives
yarn add react-spring
function Text() {
const [flip, set] = useState(false)
const props = useSpring({
to: { opacity: 1 },
from: { opacity: 0 },
reset: true,
reverse: flip,
delay: 200,
config: config.molasses,
onRest: () => set(!flip),
})
return <animated.h1 style={props}>hello</animated.h1>
}
function Number() {
const [flip, set] = useState(false)
const { number } = useSpring({
reset: true,
reverse: flip,
from: { number: 0 },
number: 1,
delay: 200,
config: config.molasses,
onRest: () => set(!flip),
})
return <animated.div>{number.to(n => n.toFixed(2))}</animated.div>
}
앞으로 프로젝트 진행하면서
react-spring
를 사용하게되면 게시글을 업데이트 하자!! 🚀