From 2fa54f59243948b33194d47854d05ba4d96c3181 Mon Sep 17 00:00:00 2001
From: john <johnbarlas39@gmail.com>
Date: Sun, 19 Mar 2017 20:30:05 +0200
Subject: [PATCH] check if there is a history prop on surface before using it

---
 .../SimpleEditor/ContainerEditor.js           | 22 ++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/app/components/SimpleEditor/ContainerEditor.js b/app/components/SimpleEditor/ContainerEditor.js
index 58f0df1..c80b368 100644
--- a/app/components/SimpleEditor/ContainerEditor.js
+++ b/app/components/SimpleEditor/ContainerEditor.js
@@ -45,20 +45,22 @@ class ContainerEditor extends SubstanceContainerEditor {
       this.addTargetToLinks()
     }
 
-    this.props.history.listenBefore((location, callback) => {
-      const commandStates = this.getCommandStates()
+    if (this.props.history) {
+      this.props.history.listenBefore((location, callback) => {
+        const commandStates = this.getCommandStates()
 
-      if (commandStates['save'].disabled === false) {
-        const editor = this.getEditor()
+        if (commandStates['save'].disabled === false) {
+          const editor = this.getEditor()
 
-        editor.send('changesNotSaved')
-        editor.emit('send:route', location.pathname)
+          editor.send('changesNotSaved')
+          editor.emit('send:route', location.pathname)
 
-        return callback(false)
-      }
+          return callback(false)
+        }
 
-      return callback()
-    })
+        return callback()
+      })
+    }
 
     window.history.pushState(null, null, document.URL)
     window.addEventListener('popstate', this.controlBackButton)
-- 
GitLab