Deprecate component-path in core ns

This commit is contained in:
Juho Teperi 2019-12-17 15:40:51 +02:00
parent ad3b6af57e
commit 106e5d86ca
2 changed files with 11 additions and 9 deletions

View File

@ -83,8 +83,8 @@
(dom/unmount-component-at-node container))
;; For backward compatibility
(def ^{:deprecated true} as-component as-element)
(def ^{:deprecated true} render-component render)
(def ^{:deprecated "0.10.0"} as-component as-element)
(def ^{:deprecated "0.10.0"} render-component render)
(defn force-update-all
"Force re-rendering of all mounted Reagent components. This is
@ -390,8 +390,9 @@
(util/make-partial-fn f args))
(defn component-path
;; Try to return the path of component c as a string.
;; Maybe useful for debugging and error reporting, but may break
;; with future versions of React (and return nil).
"Try to return the path of component c as a string.
Maybe useful for debugging and error reporting, but may break
with future versions of React (and return nil)."
{:deprecated "0.10.0"}
[c]
(comp/component-path c))

View File

@ -5,6 +5,7 @@
[reagent.debug :as debug :refer-macros [dev?]]
[reagent.core :as r]
[reagent.dom.server :as server]
[reagent.impl.component :as comp]
[reagenttest.utils :as u :refer [with-mounted-component]]
[clojure.string :as string]
[goog.string :as gstr]
@ -660,10 +661,10 @@
(deftest test-component-path
(let [a (atom nil)
tc (r/create-class {:display-name "atestcomponent"
:render (fn []
(let [c (r/current-component)]
(reset! a (r/component-path c))
[:div]))})]
:render (fn []
(let [c (r/current-component)]
(reset! a (comp/component-path c))
[:div]))})]
(with-mounted-component [tc]
(fn [c]
(is (seq @a))