Using ScrollReveal.js with React Hooks
Henrique Ramos
Posted on January 19, 2021
Today, I decided to improve my website by adding scroll reveal to it. For that, I chose jlmakes' ScrollReveal.js which solved my problem in a snap, the biggest problem was integrating it with React (Turns out, it was also a piece of cake).
The code
ScrollReveal.js provides a constructor ScrollReveal()
that returns its instance. The method reveal()
is responsible for registering the target element with ScrollReveal
, it has a target
argument (which can be a CSS Selector, a DOM Node, or an Array of Nodes) and an options
argument which allows customizing the reveal behavior. That being said, we can use useRef
hook to connect the React Node to ScrollReveal:
Posted on January 19, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.