 (defn- calculate-dimensions
   [data]
   (let [shapes (vals (:shapes-by-id data))
-        shape (geom/shapes->rect-shape shapes)]
-    {:width (+ (:x shape) (:width shape) 100)
-     :height (+ (:y shape) (:height shape) 100)}))
+        shape (geom/shapes->rect-shape shapes)
+        width (+ (:x shape) (:width shape) 100)
+        height (+ (:y shape) (:height shape) 100)]
+    {:width (if (mth/nan? width) 100 width)
+     :height (if (mth/nan? height) 100 height)}))
 
 (mf/defc shape-wrapper
   [{:keys [shape] :as props}]

        shapes (map #(get shapes-by-id %) (:shapes data []))
        canvas (map #(get shapes-by-id %) (:canvas data []))
        dim (calculate-dimensions data)]
    [:svg {:view-box (str "0 0 " (:width dim) " " (:height dim))
           :version "1.1"
           :xmlnsXlink "http://www.w3.org/1999/xlink"
           :xmlns "http://www.w3.org/2000/svg"}

  (:require
   [cljsjs.react.dom.server]
   [rumext.alpha :as mf]
   [uxbox.util.math :as mth]
   [uxbox.main.geom :as geom]
   [uxbox.main.ui.shapes.canvas :as canvas]
   [uxbox.main.ui.shapes.circle :as circle]
