mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-25 01:51:37 -04:00
16 lines
324 B
TypeScript
16 lines
324 B
TypeScript
import {useEffect, useState} from 'react'
|
|
|
|
export function inIframe() {
|
|
try {
|
|
return window.self !== window.top
|
|
} catch (_e) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
export function useIsIframe() {
|
|
const [is, setIs] = useState(false)
|
|
useEffect(() => setIs(inIframe()), []) // useEffect so this happens client side
|
|
return is
|
|
}
|