Skip to content

Instantly share code, notes, and snippets.

View blastuha's full-sized avatar
🎯
Focusing

Boris blastuha

🎯
Focusing
View GitHub Profile
@blastuha
blastuha / useIntersectionObserver.ts
Created October 31, 2023 07:42 — forked from nimone/useIntersectionObserver.ts
Add Infinite Scrolling to your ReactJS Projects using Intersection Observer
import { DependencyList, useCallback, useRef } from "react"
export default function useIntersectionObserver<T extends HTMLElement>(
callback: () => void,
deps: DependencyList
) {
const observer = useRef<IntersectionObserver | null>(null)
const ref = useCallback(
(node: T) => {