16 lines
318 B
TypeScript
16 lines
318 B
TypeScript
|
import { useEffect, useState } from 'react'
|
||
|
|
||
|
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
|
||
|
}
|