-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathDemo.js
38 lines (32 loc) · 1 KB
/
Demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from "react";
import IframeComm from "react-iframe-comm"; // loads build file
const Demo = ({ }) => {
// the html attributes to create the iframe with
// make sure you use camelCase attribute names
const attributes = {
src: "https://pbojinov.github.io/iframe-communication/iframe.html",
// name: 'Demo',
width: "100%",
height: "175"
};
// the postMessage data you want to send to your iframe
// it will be send after the iframe has loaded
const postMessageData = "hello iframe";
// parent received a message from iframe
const onReceiveMessage = () => {
console.log("handleReceiveMessage");
};
// iframe has loaded
const onReady = () => {
console.log("onReady");
};
return (
<IframeComm
attributes={attributes}
postMessageData={postMessageData}
handleReady={onReady}
handleReceiveMessage={onReceiveMessage}
/>
);
};
export default Demo;