2022-05-20 00:34:08 +00:00
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
|
2022-09-07 03:43:28 +00:00
|
|
|
export function inIframe() {
|
2022-05-20 00:34:08 +00:00
|
|
|
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
|
|
|
|
}
|