Make sure all React lifecycle callbacks are supported

This commit is contained in:
Dan Holmsand 2014-02-02 11:38:25 +01:00
parent 35bc336743
commit 1b6b4e449e
2 changed files with 11 additions and 4 deletions

View File

@ -44,7 +44,9 @@ looking like this:
{:get-initial-state (fn [this])
:component-will-receive-props (fn [this new-props])
:should-component-update (fn [this old-props new-props old-children new-children])
:component-will-mount (fn [this])
:component-did-mount (fn [this])
:component-will-update (fn [this new-props new-children])
:component-did-update (fn [this old-props old-children])
:component-will-unmount (fn [this])
:render (fn [props children this])}

View File

@ -36,7 +36,7 @@
(-> C js-props props-in-props))
(defn get-children [C]
(->> C js-props (aget cljs-children)))
(-> C js-props (aget cljs-children)))
(defn replace-props [C newprops]
(.setProps C (js-obj cljs-props newprops)))
@ -152,11 +152,16 @@
;; call f with oldprops newprops oldchildren newchildren
(f C p1 p2 c1 c2))))
:componentWillUpdate
(fn [C nextprops]
(let [p (aget nextprops cljs-props)
c (aget nextprops cljs-children)]
(f C p c)))
:componentDidUpdate
(fn [C oldprops]
(let [inprops (js-props C)
p (aget inprops cljs-props)
c (aget inprops cljs-children)]
(let [p (aget oldprops cljs-props)
c (aget oldprops cljs-children)]
(f C p c)))
:componentWillUnmount