An open API service indexing awesome lists of open source software.

https://github.com/ger86/use-observer-hook

Repository to show the use of the custom hook useObserver that integrates the API Intersection Observer with React.
https://github.com/ger86/use-observer-hook

intersection-observer javascript react react-hook react-hooks reactjs

Last synced: about 1 month ago
JSON representation

Repository to show the use of the custom hook useObserver that integrates the API Intersection Observer with React.

Awesome Lists containing this project

README

          

# 👀 useObserver hook

## Description

Project to show how we can integrate the **API Intersection Observer** with React creating a custom hook that allows us to reuse it as many times as we want.

What we will do is take advantage of the API Intersection Observer to load our images in a lazy way as we scroll down. We will integrate this functionality into the hook `useObserver` to use it wherever we need it.

## Hooks used

- `useEffect`
- `useState`
- `useRef`

## To Read More

[Intersection Observer API](https://developer.mozilla.org/es/docs/Web/API/Intersection_Observer_API)

[Javascript. Intersection Observer](https://medium.com/@ger86/javascript-intersection-observer-1410b743c991)

[React. Intersection Observer hook](https://medium.com/@ger86/react-intersection-observer-hook-e57209493ce2)