Home / Function/ useWindowLocation() — supabase Function Reference

useWindowLocation() — supabase Function Reference

Architecture documentation for the useWindowLocation() function in useWindowLocation.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  4e8ef488_182e_b5eb_54ce_a187e0eccc8e["useWindowLocation()"]
  0376d4b4_6ed2_1775_ce18_17064b244172["useIsMounted()"]
  4e8ef488_182e_b5eb_54ce_a187e0eccc8e -->|calls| 0376d4b4_6ed2_1775_ce18_17064b244172
  style 4e8ef488_182e_b5eb_54ce_a187e0eccc8e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/hooks/useWindowLocation.ts lines 4–35

const useWindowLocation = (): Location | void => {
  const isMounted = useIsMounted()
  const [location, setLocation] = useState<Location | void>(isMounted ? window.location : undefined)

  const setWindowLocation = (location) => {
    setLocation(location)
  }

  useEffect(() => {
    if (!isMounted) return

    if (!location) {
      setWindowLocation(window.location)
    }

    const handler = () => {
      setWindowLocation(window.location)
    }

    window.addEventListener('popstate', handler)

    return () => {
      window.removeEventListener('popstate', handler)
    }
  }, [isMounted])

  useEffect(() => {
    // console.log('location, in hook useffect', location)
  }, [location])

  return location
}

Subdomains

Frequently Asked Questions

What does useWindowLocation() do?
useWindowLocation() is a function in the supabase codebase.
What does useWindowLocation() call?
useWindowLocation() calls 1 function(s): useIsMounted.

Analyze Your Own Codebase

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

Try Supermodel Free