Home / Function/ useIntersectionObserver() — supabase Function Reference

useIntersectionObserver() — supabase Function Reference

Architecture documentation for the useIntersectionObserver() function in useIntersectionObserver.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  49800345_99af_55a9_d6fd_a34b97143772["useIntersectionObserver()"]
  43a612a3_ae1c_06b7_bda8_994be99d8dd4["ComboBox()"]
  43a612a3_ae1c_06b7_bda8_994be99d8dd4 -->|calls| 49800345_99af_55a9_d6fd_a34b97143772
  8c9f4578_cfa6_e337_1047_0b169262ad94["ProjectSelector()"]
  8c9f4578_cfa6_e337_1047_0b169262ad94 -->|calls| 49800345_99af_55a9_d6fd_a34b97143772
  style 49800345_99af_55a9_d6fd_a34b97143772 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/hooks/useIntersectionObserver.tsx lines 5–40

export function useIntersectionObserver<T extends Element>(
  options: {
    root?: Element | Document | null
    rootMargin?: string
    threshold?: number | number[]
  } = {}
): [RefCallback<T>, IntersectionObserverEntry | null] {
  const { threshold = 1, root = null, rootMargin = '0px' } = options
  const [entry, setEntry] = useState<IntersectionObserverEntry | null>(null)

  const previousObserver = useRef<IntersectionObserver | null>(null)

  const customRef = useCallback(
    (node) => {
      if (previousObserver.current) {
        previousObserver.current.disconnect()
        previousObserver.current = null
      }

      if (node?.nodeType === Node.ELEMENT_NODE) {
        const observer = new IntersectionObserver(
          ([entry]) => {
            setEntry(entry)
          },
          { threshold, root, rootMargin }
        )

        observer.observe(node)
        previousObserver.current = observer
      }
    },
    [threshold, root, rootMargin]
  )

  return [customRef, entry]
}

Subdomains

Frequently Asked Questions

What does useIntersectionObserver() do?
useIntersectionObserver() is a function in the supabase codebase.
What calls useIntersectionObserver()?
useIntersectionObserver() is called by 2 function(s): ComboBox, ProjectSelector.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free