Skip to content

Commit 2a03843

Browse files
committed
allow defined heights to be passed in
1 parent 34c4d85 commit 2a03843

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/App.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useState, useEffect } from "react";
33

44
const App = () => {
55
const sample = {
6-
example: "value",
6+
name: "value",
77
example2: 19999,
88
example3: { hello: "world" },
99
input: "",
@@ -24,7 +24,7 @@ const App = () => {
2424
const [retoolData, setRetoolData] = useState("");
2525
const [data, setData] = useState(sample);
2626
return (
27-
<div style={{ height: "500px" }}>
27+
<div>
2828
<button
2929
onClick={() => {
3030
setData({ ...data, example2: "new value" });
@@ -41,8 +41,10 @@ const App = () => {
4141
<h1> {retoolData} </h1>
4242
<p id="hello"> {JSON.stringify(data)} </p>
4343
<Retool
44-
url="https://support.retool.com/apps/Ben/parent%20window%20query123"
44+
url="https://support.retool.com/embedded/public/cb9e15f0-5d7c-43a7-a746-cdec870dde9a"
4545
data={data}
46+
height="500px"
47+
width="500px"
4648
></Retool>
4749
</div>
4850
);

src/components/Retool.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useRef, useState } from "react";
22

3-
const Retool = ({ data, url }) => {
3+
const Retool = ({ data, url, height, width }) => {
44
const embeddedIframe = useRef(null);
55
const [elementWatchers, setElementWatchers] = useState({});
66

@@ -34,7 +34,6 @@ const Retool = ({ data, url }) => {
3434

3535
window.addEventListener("message", handler);
3636

37-
// clean up
3837
return () => window.removeEventListener("message", handler);
3938
}, []);
4039

@@ -74,8 +73,8 @@ const Retool = ({ data, url }) => {
7473

7574
return (
7675
<iframe
77-
height="100%"
78-
width="100%"
76+
height={height ?? "100%"}
77+
width={width ?? "100%"}
7978
frameBorder="none"
8079
src={url}
8180
ref={embeddedIframe}

0 commit comments

Comments
 (0)