I have a react function component that needs to use a framer motion hook to build up the props of an object called styles, however you can’t use hooks conditionally, so I’d like to know how to use hooks conditionally?
let styles = {};
if (scaleUp) {
styles.scale = useTransform(scrollYProgress, [0, 1], [1, 1.2]);
}
if (scaleDown) {
styles.scale = useTransform(scrollYProgress, [0, 1], [1.2, 1]);
}
if (fadeIn) {
styles.opacity = useTransform(scrollYProgress, [0, 1], [0, 1]);
}
if (fadeOut) {
styles.opacity = useTransform(scrollYProgress, [0, 1], [1, 0]);
}