 
 (defn as-class [tag]
   (if (hiccup-tag? tag)
-    (cached-wrapper tag)
-    (do
-      (let [cached-class (util/cached-react-class tag)]
-        (if-not (nil? cached-class)
-          cached-class
-          (if (.' js/React isValidElement tag)
-            (util/cache-react-class tag (wrap-component tag nil nil))
-            (fn-to-class tag)))))))
+    (cached-wrapper tag)    
+    (let [cached-class (util/cached-react-class tag)]
+      (if-not (nil? cached-class)
+        cached-class
+        (if (.' js/React isValidElement tag)
+          (util/cache-react-class tag (wrap-component tag nil nil))
+          (fn-to-class tag))))))
 
 (defn get-key [x]
   (when (map? x) (get x :key)))


(defn input-component? [x]
  (let [DOM (.' js/React :DOM)]
    (or (identical? x (.' DOM :input))
        (identical? x (.' DOM :textarea)))))


;;; Wrapping of native components

(declare convert-args)

(defn wrapped-render [this comp id-class input-setup]
  (let [inprops (.' this :props)
        argv (.' inprops :argv)
        props (nth argv 1 nil)
        hasprops (or (nil? props) (map? props))
        jsprops (convert-props (if hasprops props) id-class)
        jsargs (convert-args argv comp jsprops
                             (if hasprops 2 1)
                             (inc (.' inprops :level)))]
    (when-not (nil? input-setup)
      (input-setup this jsprops))
    (.apply (.' js/React :createElement) nil jsargs)))

(defn wrapped-should-update [c nextprops nextstate]
  (or util/*always-update*

      (aset a i (as-component (aget a i) level')))
    a))

(defn make-element [argv comp jsprops first-child level]
  (if (== (count argv) (inc first-child))
    ;; Optimize common case of one child
    (.' js/React createElement comp jsprops
        (as-component (nth argv first-child) level))
    (.apply (.' js/React :createElement) nil
            (reduce-kv (fn [a k v]
                         (when (>= k first-child)
                           (.push a (as-component v level)))
                         a)
                       #js[comp jsprops] argv))))
