diff --git a/src/devcards/core.cljs b/src/devcards/core.cljs index 270ea09..ef94bd6 100644 --- a/src/devcards/core.cljs +++ b/src/devcards/core.cljs @@ -21,6 +21,14 @@ ;; this channel is only used for card registration notifications (defonce devcard-event-chan (chan)) +(def react-element-type-symbol + "Make a react Symbol the same way as React 0.14" + (or (and (exists? js/Symbol) + (fn? js/Symbol) + (.-for js/Symbol) + ((.-for js/Symbol) "react.element")) + 0xeac7)) + ;; its possible to record the meta-data for the loaded ns's being ;; shipped by figwheel, by ataching a before load listener and storing ;; the meta data, might be better to have figwheel do that. @@ -358,7 +366,9 @@ :value x}))) (defn react-element? [main-obj] - (aget main-obj "_isReactElement")) + (or (aget main-obj "_isReactElement") ;; react 0.13 + (= react-element-type-symbol ;; react 0.14 + (.-$$typeof main-obj)))) (defn validate-card-options [opts] (if (map? opts) diff --git a/src/devcards/system.cljs b/src/devcards/system.cljs index 56d1ff0..2c87be4 100644 --- a/src/devcards/system.cljs +++ b/src/devcards/system.cljs @@ -412,7 +412,8 @@ (defn start-ui-with-renderer [channel renderer] (defonce devcards-ui-setup (do - (js/React.initializeTouchEvents true) + (when (exists? js/React.initializeTouchEvents) + (js/React.initializeTouchEvents true)) (go (