mirror of https://github.com/status-im/reagent.git
Use findDOMNode instead of ref to manage ReagentInput
This commit is contained in:
parent
b4ec13f003
commit
0303c6ddef
|
@ -109,7 +109,7 @@
|
|||
(contains? these-inputs-have-selection-api input-type))
|
||||
|
||||
(defn input-set-value [this]
|
||||
(when-some [node ($ this :cljsInputElement)]
|
||||
(when-some [node ($ util/react-dom findDOMNode this)]
|
||||
($! this :cljsInputDirty false)
|
||||
(let [rendered-value ($ this :cljsRenderedValue)
|
||||
dom-value ($ this :cljsDOMValue)]
|
||||
|
@ -174,19 +174,15 @@
|
|||
(.hasOwnProperty jsprops "value"))
|
||||
(let [v ($ jsprops :value)
|
||||
value (if (nil? v) "" v)
|
||||
on-change ($ jsprops :onChange)
|
||||
original-ref ($ jsprops :ref)]
|
||||
(when (nil? ($ this :cljsInputElement))
|
||||
on-change ($ jsprops :onChange)]
|
||||
(when (nil? ($ this :cljsDOMValue))
|
||||
;; set initial value
|
||||
($! this :cljsDOMValue value))
|
||||
($! this :cljsRenderedValue value)
|
||||
(js-delete jsprops "value")
|
||||
(doto jsprops
|
||||
($! :defaultValue value)
|
||||
($! :onChange #(input-handle-change this on-change %))
|
||||
($! :ref (fn [el]
|
||||
(if original-ref (original-ref el))
|
||||
($! this :cljsInputElement el)))))))
|
||||
($! :onChange #(input-handle-change this on-change %))))))
|
||||
|
||||
(defn ^boolean input-component? [x]
|
||||
(case x
|
||||
|
|
|
@ -10,6 +10,13 @@
|
|||
(throw (js/Error. "require('react') failed")))
|
||||
:else (throw (js/Error. "js/React is missing"))))
|
||||
|
||||
(defonce react-dom
|
||||
(cond (exists? js/ReactDOM) js/ReactDOM
|
||||
(exists? js/require) (or (js/require "react-dom")
|
||||
(throw (js/Error. "require('react-dom') failed")))
|
||||
:else
|
||||
(throw (js/Error. "js/ReactDOM is missing"))))
|
||||
|
||||
(def is-client (and (exists? js/window)
|
||||
(-> js/window ($ :document) nil? not)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue