Skip to content

Commit 5977faf

Browse files
author
Ives van Hoorne
committed
Fix changing URL with no preview
1 parent a7069a8 commit 5977faf

File tree

1 file changed

+18
-14
lines changed
  • packages/app/src/app/components/Preview

1 file changed

+18
-14
lines changed

packages/app/src/app/components/Preview/index.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,28 +242,32 @@ class BasePreview extends React.Component<Props, State> {
242242
sendUrl = () => {
243243
const { urlInAddressBar } = this.state;
244244

245-
// $FlowIssue
246-
document.getElementById('sandbox').src = urlInAddressBar;
245+
if (document.getElementById('sandbox')) {
246+
// $FlowIssue
247+
document.getElementById('sandbox').src = urlInAddressBar;
247248

248-
this.setState({
249-
history: [urlInAddressBar],
250-
historyPosition: 0,
251-
urlInAddressBar,
252-
});
249+
this.setState({
250+
history: [urlInAddressBar],
251+
historyPosition: 0,
252+
urlInAddressBar,
253+
});
254+
}
253255
};
254256

255257
handleRefresh = () => {
256258
const { history, historyPosition, urlInAddressBar } = this.state;
257259
const url = history[historyPosition] || urlInAddressBar;
258260

259-
// $FlowIssue
260-
document.getElementById('sandbox').src = url;
261+
if (document.getElementById('sandbox')) {
262+
// $FlowIssue
263+
document.getElementById('sandbox').src = url;
261264

262-
this.setState({
263-
history: [url],
264-
historyPosition: 0,
265-
urlInAddressBar: url,
266-
});
265+
this.setState({
266+
history: [url],
267+
historyPosition: 0,
268+
urlInAddressBar: url,
269+
});
270+
}
267271
};
268272

269273
handleBack = () => {

0 commit comments

Comments
 (0)