-
-
Save mikowl/4c2a765f6194f5eb3c9ccbeb5bca14d5 to your computer and use it in GitHub Desktop.
Auto Animate Component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ElementType, HTMLAttributes } from "react"; | |
import { useAutoAnimate } from "@formkit/auto-animate/react"; | |
interface Props extends HTMLAttributes<HTMLElement> { | |
as?: ElementType; | |
} | |
export const AutoAnimate: React.FC<Props> = ({ | |
as: Tag = "div", | |
children, | |
...rest | |
}) => { | |
const [ref] = useAutoAnimate<HTMLElement>(); | |
return ( | |
<Tag ref={ref} {...rest}> | |
{children} | |
</Tag> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment