       (when (and wrap f)
         (assert (fn? f)
                 (str "Expected function in " name key " but got " f)))
-      (default-wrapper (or wrap f)))))
+      (or wrap (default-wrapper f)))))
 
 (def obligatory {:shouldComponentUpdate nil
                  :componentWillUnmount nil})

      (this-as C (apply f C args)))
    f))

(def dont-wrap #{:cljsRender})

(defn get-wrapper [key f name]
  (if (dont-wrap key)

    (assert false "getDefaultProps not supported yet")
    
    :getInitialState
    (fn []
      (this-as C
               (when f
                 (aset C cljs-state (merge (state C) (f C))))))

    :componentWillReceiveProps
    (fn [props]
      (this-as C
               (when f (f C (aget props cljs-argv)))))

    :shouldComponentUpdate
    (fn [nextprops nextstate]
      (this-as C
               ;; Don't care about nextstate here, we use forceUpdate
               ;; when only when state has changed anyway.
               (let [inprops (js-props C)
                     old-argv (aget inprops cljs-argv)
                     new-argv (aget nextprops cljs-argv)]
                 (if (nil? f)
                   (not (util/equal-args old-argv new-argv))
                   (f C old-argv new-argv)))))

    :componentWillUpdate
    (fn [nextprops]
      (this-as C
               (let [next-argv (aget nextprops cljs-argv)]
                 (f C next-argv))))

    :componentDidUpdate
    (fn [oldprops]
      (this-as C
               (let [old-argv (aget oldprops cljs-argv)]
                 (f C old-argv))))

    :componentWillUnmount
    (fn []
      (this-as C
               (let [ratom (.-cljsRatom C)]
                 (if-not (nil? ratom)
                   (ratom/dispose! ratom)))
               (set! (.-cljsIsDirty C) false)
               (when f (f C))))

    nil))

