mirror of
https://github.com/supabase/supabase.git
synced 2026-10-19 16:19:10 +03:00
20 lines
462 B
TypeScript
20 lines
462 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import { useWindowSize } from 'react-use'
|
|
import { isBrowser } from '../helpers'
|
|
|
|
export function useBreakpoint(breakpoint = 768) {
|
|
if (!isBrowser) return
|
|
const [isBreakpoint, setIsBreakpoint] = useState(false)
|
|
const { width } = useWindowSize()
|
|
|
|
useEffect(() => {
|
|
if (width <= breakpoint) {
|
|
setIsBreakpoint(true)
|
|
} else {
|
|
setIsBreakpoint(false)
|
|
}
|
|
}, [width])
|
|
|
|
return isBreakpoint
|
|
}
|