mirror of https://github.com/status-im/reagent.git
Revert ref support for the time being
There might be a more elegant way of supporting refs...
This commit is contained in:
parent
2bb32eb21f
commit
1555fd9c3e
|
@ -105,15 +105,6 @@ Everything is optional, except :render.
|
||||||
[this]
|
[this]
|
||||||
(.getDOMNode this))
|
(.getDOMNode this))
|
||||||
|
|
||||||
(defn ref [parent key child]
|
|
||||||
(assert (util/reagent-component? parent))
|
|
||||||
(assert (keyword? key) (str "Key must be a keyword, not " (pr-str key)))
|
|
||||||
(tmpl/make-ref-component parent key child))
|
|
||||||
|
|
||||||
(defn refs [this]
|
|
||||||
(assert (util/reagent-component? this))
|
|
||||||
(tmpl/get-refs this))
|
|
||||||
|
|
||||||
|
|
||||||
(defn merge-props
|
(defn merge-props
|
||||||
"Utility function that merges two maps, handling :class and :style
|
"Utility function that merges two maps, handling :class and :style
|
||||||
|
|
|
@ -170,48 +170,6 @@
|
||||||
(comp/create-class spec as-component))
|
(comp/create-class spec as-component))
|
||||||
|
|
||||||
|
|
||||||
;;; Ref support
|
|
||||||
|
|
||||||
(def cljs-refs "cljsRefs")
|
|
||||||
|
|
||||||
(defn update-ref [this]
|
|
||||||
(let [rd (-> this util/get-props :ref-data)
|
|
||||||
{:keys [parent ref]} rd
|
|
||||||
refed (-> this (aget "refs") (aget (name ref)))]
|
|
||||||
(aset parent cljs-refs
|
|
||||||
(-> (aget parent cljs-refs)
|
|
||||||
(assoc (keyword ref) refed)))))
|
|
||||||
|
|
||||||
(def ref-component
|
|
||||||
(create-class
|
|
||||||
{:displayName "ref-component"
|
|
||||||
:component-did-mount update-ref
|
|
||||||
:component-did-update update-ref
|
|
||||||
:component-will-unmount
|
|
||||||
(fn [this]
|
|
||||||
(let [rd (-> this util/get-props :ref-data)
|
|
||||||
{:keys [parent ref]} rd
|
|
||||||
refed (-> this (aget "refs") (aget (name ref)))]
|
|
||||||
(aset parent cljs-refs
|
|
||||||
(-> (aget parent cljs-refs)
|
|
||||||
(dissoc (keyword ref))))))
|
|
||||||
:render
|
|
||||||
(fn [this]
|
|
||||||
(let [rd (-> this util/get-props :ref-data)
|
|
||||||
{:keys [parent ref child]} rd
|
|
||||||
react-comp (as-component child)]
|
|
||||||
(-> react-comp (aget "props") (aset "ref" (name ref)))
|
|
||||||
react-comp))}))
|
|
||||||
|
|
||||||
(defn make-ref-component [parent ref child]
|
|
||||||
[ref-component {:ref-data {:parent parent
|
|
||||||
:ref ref
|
|
||||||
:child child}}])
|
|
||||||
|
|
||||||
(defn get-refs [this]
|
|
||||||
(aget this cljs-refs))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Conversion from Hiccup forms
|
;;; Conversion from Hiccup forms
|
||||||
|
|
||||||
(defn parse-tag [hiccup-tag]
|
(defn parse-tag [hiccup-tag]
|
||||||
|
|
Loading…
Reference in New Issue