mirror of https://github.com/status-im/reagent.git
Fix component-path on React 16 + advanced optimized built
This commit is contained in:
parent
5f47f8e9f0
commit
3cc2c473cb
|
@ -285,16 +285,21 @@
|
||||||
|
|
||||||
(defn component-path [c]
|
(defn component-path [c]
|
||||||
;; Alternative branch for React 16
|
;; Alternative branch for React 16
|
||||||
(if-let [fiber (some-> c ($ :_reactInternalFiber))]
|
;; Try both original name (for UMD foreign-lib) and manged name (property access, for Closure optimized React)
|
||||||
|
(if-let [fiber (or (some-> c ($ :_reactInternalFiber))
|
||||||
|
(some-> c (.-_reactInternalFiber)))]
|
||||||
(fiber-component-path fiber)
|
(fiber-component-path fiber)
|
||||||
(let [elem (or (some-> (or (some-> c ($ :_reactInternalInstance))
|
(let [instance (or (some-> c ($ :_reactInternalInstance))
|
||||||
c)
|
(some-> c (.-_reactInternalInstance))
|
||||||
($ :_currentElement)))
|
c)
|
||||||
|
elem (or (some-> instance ($ :_currentElement))
|
||||||
|
(some-> instance (.-_currentElement)))
|
||||||
name (some-> elem
|
name (some-> elem
|
||||||
($ :type)
|
($ :type)
|
||||||
($ :displayName))
|
($ :displayName))
|
||||||
path (some-> elem
|
owner (or (some-> elem ($ :_owner))
|
||||||
($ :_owner)
|
(some-> elem (.-_owner)))
|
||||||
|
path (some-> owner
|
||||||
component-path
|
component-path
|
||||||
(str " > "))
|
(str " > "))
|
||||||
res (str path name)]
|
res (str path name)]
|
||||||
|
|
Loading…
Reference in New Issue