From 3cc2c473cb9487eb9d4c8f92ba65aef7742977c9 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Tue, 13 Mar 2018 21:34:04 +0200 Subject: [PATCH] Fix component-path on React 16 + advanced optimized built --- src/reagent/impl/component.cljs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/reagent/impl/component.cljs b/src/reagent/impl/component.cljs index d3f9538..90b5397 100644 --- a/src/reagent/impl/component.cljs +++ b/src/reagent/impl/component.cljs @@ -285,16 +285,21 @@ (defn component-path [c] ;; 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) - (let [elem (or (some-> (or (some-> c ($ :_reactInternalInstance)) - c) - ($ :_currentElement))) + (let [instance (or (some-> c ($ :_reactInternalInstance)) + (some-> c (.-_reactInternalInstance)) + c) + elem (or (some-> instance ($ :_currentElement)) + (some-> instance (.-_currentElement))) name (some-> elem ($ :type) ($ :displayName)) - path (some-> elem - ($ :_owner) + owner (or (some-> elem ($ :_owner)) + (some-> elem (.-_owner))) + path (some-> owner component-path (str " > ")) res (str path name)]