react-iframe
- Version 2.0.1
- Published
- 61.6 kB
- No dependencies
- ISC license
Install
npm i react-iframeyarn add react-iframepnpm add react-iframeOverview
A zero-dependency, typed, ref-forwarding iframe component for React 18+
Index
Variables
Functions
Type Aliases
Variables
variable Iframe
const Iframe: react.ForwardRefExoticComponent<any>;Functions
function postToIframe
postToIframe: ( iframe: HTMLIFrameElement | null | undefined, message: unknown, targetOrigin: string) => boolean;Post a message to an iframe's
contentWindow. Returnsfalsewhen the iframe is missing or not yet ready.targetOriginis required. Use the child's origin. For asrcDocframe the origin is opaque and the browser rejects"null"— pass"*".
function useIframeMessage
useIframeMessage: ( handler: (event: MessageEvent) => void, options?: UseIframeMessageOptions) => void;Subscribe to
window"message"events from framed documents. Pair withpostToIframeorref.current.contentWindow.postMessage.
Type Aliases
type IframeMessageSource
type IframeMessageSource = | Window | HTMLIFrameElement | RefObject<HTMLIFrameElement | null | undefined>;type IframeProps
type IframeProps = NativeIframeProps & Conveniences & (WithUrl | WithSrc | WithSrcDoc);type SandboxToken
type SandboxToken = | 'allow-downloads' | 'allow-downloads-without-user-activation' | 'allow-forms' | 'allow-modals' | 'allow-orientation-lock' | 'allow-pointer-lock' | 'allow-popups' | 'allow-popups-to-escape-sandbox' | 'allow-presentation' | 'allow-same-origin' | 'allow-scripts' | 'allow-storage-access-by-user-activation' | 'allow-top-navigation' | 'allow-top-navigation-by-user-activation' | 'allow-top-navigation-to-custom-protocols';type SandboxValue
type SandboxValue = SandboxToken | (string & {});type UseIframeMessageOptions
type UseIframeMessageOptions = { /** * When set, messages from other origins are ignored. * A `srcDoc` frame has origin `"null"` (the string). */ origin?: string; /** * When set, messages whose `event.source` is not this frame's * `contentWindow` are ignored. Prefer this over origin-only filtering * when several frames share an origin. */ source?: IframeMessageSource | null;};Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (18)
Peer Dependencies (2)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/react-iframe.
- Markdown[](https://www.jsdocs.io/package/react-iframe)
- HTML<a href="https://www.jsdocs.io/package/react-iframe"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 1843 ms. - Missing or incorrect documentation? Open an issue for this package.
