Skip to content

Commit 6eee3a7

Browse files
committed
Better error handling.
1 parent 5fc2064 commit 6eee3a7

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

dst/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-retool",
3-
"version": "0.1.9",
3+
"version": "0.2.0",
44
"private": false,
55
"repository": {
66
"type": "git",

src/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import Retool from './components/Retool'
33

44
function App() {
55
return (
6-
<Retool url="https://retoolin.tryretool.com/embedded/public/f7607e1f-670a-4ebf-9a09-be54cf17181e"/>
6+
// <Retool/>
7+
<Retool url="https://retoolin.tryretool.com/embedded/public/f7607e1f-670a-4ebf-9a09-be54cf17181e"></Retool>
78
);
89
}
910

src/components/Retool.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import './retool.css';
44
class Retool extends React.Component {
55
constructor(props) {
66
super(props);
7+
8+
if (!this.props.url) throw new Error('Please pass a url into the Retool component.')
9+
710
this.state = {
811
url: props.url,
912
elementWatchers: {}
@@ -16,7 +19,9 @@ class Retool extends React.Component {
1619
}
1720

1821
startListening = () => {
19-
window.addEventListener('message', (e) => this.handle(e) );
22+
if (this.iframe) {
23+
window.addEventListener('message', (e) => this.handle(e) );
24+
}
2025
}
2126

2227
startWatchers = () => {
@@ -96,15 +101,15 @@ class Retool extends React.Component {
96101

97102
render() {
98103
return (
99-
<iframe
100-
frameBorder="none"
101-
src={this.state.url}
102-
ref = {e => {
103-
this.iframe = e
104-
}}
105-
>
106-
</iframe>
107-
);
104+
<iframe
105+
frameBorder="none"
106+
src={this.state.url}
107+
ref = {e => {
108+
this.iframe = e
109+
}}
110+
>
111+
</iframe>
112+
);
108113
}
109114
}
110115

0 commit comments

Comments
 (0)