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,22 +271,35 @@
|
||||||
cljsify
|
cljsify
|
||||||
create-react-class))
|
create-react-class))
|
||||||
|
|
||||||
(defn component-path [c]
|
(defn fiber-component-path [fiber]
|
||||||
;; Looks like in React 16, reactInternalFiber is the elem
|
(let [name (some-> fiber
|
||||||
(let [elem (or (some-> c ($ :_reactInternalFiber))
|
|
||||||
(some-> (or (some-> c ($ :_reactInternalInstance))
|
|
||||||
c)
|
|
||||||
($ :_currentElement)))
|
|
||||||
name (some-> elem
|
|
||||||
($ :type)
|
($ :type)
|
||||||
($ :displayName))
|
($ :displayName))
|
||||||
path (some-> elem
|
parent (some-> fiber
|
||||||
($ :_owner)
|
($ :return))
|
||||||
component-path
|
path (some-> parent
|
||||||
|
fiber-component-path
|
||||||
(str " > "))
|
(str " > "))
|
||||||
res (str path name)]
|
res (str path name)]
|
||||||
(when-not (empty? res) res)))
|
(when-not (empty? res) res)))
|
||||||
|
|
||||||
|
(defn component-path [c]
|
||||||
|
;; 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
|
||||||
|
($ :type)
|
||||||
|
($ :displayName))
|
||||||
|
path (some-> elem
|
||||||
|
($ :_owner)
|
||||||
|
component-path
|
||||||
|
(str " > "))
|
||||||
|
res (str path name)]
|
||||||
|
(when-not (empty? res) res))))
|
||||||
|
|
||||||
(defn comp-name []
|
(defn comp-name []
|
||||||
(if (dev?)
|
(if (dev?)
|
||||||
(let [c *current-component*
|
(let [c *current-component*
|
||||||
|
|
Loading…
Reference in New Issue