Created
July 3, 2020 11:59
-
-
Save marekpiechut/26701897c11c232b7fc312dec6425531 to your computer and use it in GitHub Desktop.
Get lazy loading cheap with IntersectionObserver in React
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
| const ExerciseItem = ({ exercise }: Props) => { | |
| const [url, setUrl] = useState<?string>(null) | |
| useEffect(() => { | |
| thumbLoader(media).then(setUrl) | |
| }, [media, thumbLoader]) | |
| return <div css={styles.thumb} style={{ backgroundImage: `url(${url})` }} /> | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment