Skip to content

Commit 0020fbc

Browse files
author
Bruce Hauman
committed
Merge pull request #58 from minimal/react0.14
Support react v0.14
2 parents 7b901e4 + 0042ef8 commit 0020fbc

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/devcards/core.cljs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
;; this channel is only used for card registration notifications
2222
(defonce devcard-event-chan (chan))
2323

24+
(def react-element-type-symbol
25+
"Make a react Symbol the same way as React 0.14"
26+
(or (and (exists? js/Symbol)
27+
(fn? js/Symbol)
28+
(aget js/Symbol "for")
29+
((aget js/Symbol "for") "react.element"))
30+
0xeac7))
31+
2432
;; its possible to record the meta-data for the loaded ns's being
2533
;; shipped by figwheel, by ataching a before load listener and storing
2634
;; the meta data, might be better to have figwheel do that.
@@ -358,7 +366,9 @@
358366
:value x})))
359367

360368
(defn react-element? [main-obj]
361-
(aget main-obj "_isReactElement"))
369+
(or (aget main-obj "_isReactElement") ;; react 0.13
370+
(= react-element-type-symbol ;; react 0.14
371+
(aget main-obj "$$typeof"))))
362372

363373
(defn validate-card-options [opts]
364374
(if (map? opts)

src/devcards/system.cljs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@
412412
(defn start-ui-with-renderer [channel renderer]
413413
(defonce devcards-ui-setup
414414
(do
415-
(js/React.initializeTouchEvents true)
415+
(when (exists? js/React.initializeTouchEvents)
416+
(js/React.initializeTouchEvents true))
416417
(go
417418
(<! (load-data-from-channel! channel))
418419

@@ -434,7 +435,8 @@
434435
(defn start-ui [channel]
435436
(defonce devcards-ui-setup
436437
(do
437-
(js/React.initializeTouchEvents true)
438+
(when (exists? js/React.initializeTouchEvents)
439+
(js/React.initializeTouchEvents true))
438440
(render-base-if-necessary!)
439441
(go
440442
;; initial load

0 commit comments

Comments
 (0)