mirror of https://github.com/status-im/reagent.git
Don't use ilookup for props, children, etc.
This commit is contained in:
parent
89e7392269
commit
9e5e38fbc7
2
Makefile
2
Makefile
|
@ -9,7 +9,7 @@ PROF = dev,test
|
|||
CLJSBUILD = client
|
||||
CLJSDIRS = src test
|
||||
|
||||
VERSION = 0.0.1-SNAPSHOT
|
||||
VERSION = 0.0.2-SNAPSHOT
|
||||
|
||||
all: buildrun
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
|
||||
(defproject simple-cloact "0.0.1"
|
||||
(defproject simple-cloact "0.0.2-SNAPSHOT"
|
||||
:dependencies [[org.clojure/clojurescript "0.0-2120"]
|
||||
[cloact "0.0.1"]]
|
||||
[cloact "0.0.2-SNAPSHOT"]]
|
||||
:plugins [[lein-cljsbuild "1.0.0"]]
|
||||
:hooks [leiningen.cljsbuild]
|
||||
:profiles {:prod {:cljsbuild
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
|
||||
(defproject todomvc-cloact "0.0.1"
|
||||
(defproject todomvc-cloact "0.0.2-SNAPSHOT"
|
||||
:dependencies [[org.clojure/clojurescript "0.0-2120"]
|
||||
[cloact "0.0.1"]]
|
||||
[cloact "0.0.2-SNAPSHOT"]]
|
||||
:plugins [[lein-cljsbuild "1.0.0"]]
|
||||
:hooks [leiningen.cljsbuild]
|
||||
:profiles {:prod {:cljsbuild
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
nil)})])))
|
||||
|
||||
(def todo-input (with-meta todo-input-render
|
||||
{:component-did-mount #(.focus (:dom-node %))}))
|
||||
{:component-did-mount #(.focus (cloact/dom-node %))}))
|
||||
|
||||
(defn todo-item [{:keys [todo on-toggle on-save on-destroy]} this]
|
||||
(dbg "Rendering item")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
|
||||
(defproject cloact "0.0.1"
|
||||
(defproject cloact "0.0.2-SNAPSHOT"
|
||||
:dependencies [[org.clojure/clojurescript "0.0-2120"]]
|
||||
:plugins [[lein-cljsbuild "1.0.1"]]
|
||||
:hooks [leiningen.cljsbuild]
|
||||
|
|
|
@ -9,31 +9,52 @@
|
|||
|
||||
(def React tmpl/React)
|
||||
|
||||
(defn create-class [body]
|
||||
(comp/create-class body))
|
||||
|
||||
(defn as-component [comp]
|
||||
(tmpl/as-component comp))
|
||||
;; (defn as-component [comp]
|
||||
;; (tmpl/as-component comp))
|
||||
|
||||
(defn render-component
|
||||
([comp container]
|
||||
(render-component comp container nil))
|
||||
([comp container callback]
|
||||
(.renderComponent React (as-component comp) container callback)))
|
||||
(.renderComponent React (tmpl/as-component comp) container callback)))
|
||||
|
||||
(defn unmount-component-at-node [container]
|
||||
(.unmountComponentAtNode React container))
|
||||
|
||||
(defn render-component-to-string [component callback]
|
||||
(.renderComponentToString React (as-component component) callback))
|
||||
(.renderComponentToString React (tmpl/as-component component) callback))
|
||||
|
||||
(defn set-props [C props]
|
||||
(comp/set-props C props))
|
||||
(defn create-class [body]
|
||||
(comp/create-class body))
|
||||
|
||||
(defn replace-props [C props]
|
||||
(comp/replace-props C props))
|
||||
|
||||
(defn merge-props [defaults props]
|
||||
|
||||
(defn set-props [comp props]
|
||||
(comp/set-props comp props))
|
||||
|
||||
(defn replace-props [comp props]
|
||||
(comp/replace-props comp props))
|
||||
|
||||
|
||||
|
||||
(defn props [comp]
|
||||
(comp/get-props comp))
|
||||
|
||||
(defn children [comp]
|
||||
(comp/get-children comp))
|
||||
|
||||
(defn dom-node [comp]
|
||||
(.getDOMNode comp))
|
||||
|
||||
(defn refs [comp]
|
||||
(.-refs comp))
|
||||
|
||||
|
||||
|
||||
(defn merge-props
|
||||
"Utility function that merges two maps, handling :class and :style
|
||||
specially, like React's transferPropsTo."
|
||||
[defaults props]
|
||||
(util/merge-props defaults props))
|
||||
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
(def -ToExtend (js-obj))
|
||||
(set! (.-prototype -ToExtend) CloactMixin)
|
||||
|
||||
(declare get-props)
|
||||
(declare get-children)
|
||||
;; (declare get-props)
|
||||
;; (declare get-children)
|
||||
|
||||
(extend-type -ToExtend
|
||||
IEquiv
|
||||
|
@ -39,17 +39,6 @@
|
|||
(-add-watch [C key f] (assert false "Component isn't really watchable"))
|
||||
(-remove-watch [C key] (assert false "Component isn't really watchable"))
|
||||
|
||||
ILookup
|
||||
(-lookup [C key]
|
||||
(-lookup C key nil))
|
||||
(-lookup [C key not-found]
|
||||
(case key
|
||||
:props (get-props C)
|
||||
:children (get-children C)
|
||||
:dom-node (.getDOMNode C)
|
||||
:refs (.-refs C)
|
||||
not-found))
|
||||
|
||||
IHash
|
||||
(-hash [C] (goog/getUid C)))
|
||||
|
||||
|
@ -103,7 +92,7 @@
|
|||
|
||||
(defn- do-render [C f]
|
||||
(set! (.-isRenderContext ratom/*ratom-context*) true)
|
||||
(let [res (f (cljs-props C) C @C)
|
||||
(let [res (f (cljs-props C) C)
|
||||
conv (if (vector? res)
|
||||
(tmpl/as-component res)
|
||||
(if (fn? res)
|
||||
|
|
Loading…
Reference in New Issue