mirror of https://github.com/status-im/reagent.git
Fix component-path on React 16
This commit is contained in:
parent
39b0326d22
commit
3fd0f1b1d8
|
@ -271,10 +271,23 @@
|
|||
cljsify
|
||||
create-react-class))
|
||||
|
||||
(defn fiber-component-path [fiber]
|
||||
(let [name (some-> fiber
|
||||
($ :type)
|
||||
($ :displayName))
|
||||
parent (some-> fiber
|
||||
($ :return))
|
||||
path (some-> parent
|
||||
fiber-component-path
|
||||
(str " > "))
|
||||
res (str path name)]
|
||||
(when-not (empty? res) res)))
|
||||
|
||||
(defn component-path [c]
|
||||
;; Looks like in React 16, reactInternalFiber is the elem
|
||||
(let [elem (or (some-> c ($ :_reactInternalFiber))
|
||||
(some-> (or (some-> c ($ :_reactInternalInstance))
|
||||
;; Alternative branch for React 16
|
||||
(if-let [fiber (some-> c ($ :_reactInternalFiber))]
|
||||
(fiber-component-path fiber)
|
||||
(let [elem (or (some-> (or (some-> c ($ :_reactInternalInstance))
|
||||
c)
|
||||
($ :_currentElement)))
|
||||
name (some-> elem
|
||||
|
@ -285,7 +298,7 @@
|
|||
component-path
|
||||
(str " > "))
|
||||
res (str path name)]
|
||||
(when-not (empty? res) res)))
|
||||
(when-not (empty? res) res))))
|
||||
|
||||
(defn comp-name []
|
||||
(if (dev?)
|
||||
|
|
Loading…
Reference in New Issue