Created
September 26, 2021 09:49
-
-
Save captain-woof/3942dc46e60ac7e4f3a9377801cf83fa to your computer and use it in GitHub Desktop.
React Intersection Revealer Quick Start Example
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 React, {useRef} from 'react' | |
| import {useIntersectionRevealer} from 'react-intersection-revealer' | |
| export default function YourAwesomeComponent(){ | |
| const ref = useRef() | |
| const {heightVisible} = useIntersectionRevealer(ref) | |
| return( | |
| <> | |
| <div className="need-to-track" ref={ref}>...</div> | |
| <p>{`${heightVisible}px (height) of the tracked element is on screen`}</p> | |
| </> | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment