   ;; set-state! always triggers render, unless shouldComponentUpdate returns false.
   ;; if we assume that if state hasn't changed we don't re-render,
   ;; controlled inputs break.
-  (set! (.. this -state -cljs$previousState)
-        (.. this -state -cljs$state))
-  (set! (.. this -state -cljs$state)
-        new-state)
+  (swap! component-state update this #(-> %
+                                          (assoc :prev-state (:state %))
+                                          (assoc :state new-state)))
   (when-let [will-receive-state (.-componentWillReceiveState this)]
     (.call will-receive-state this))
   (when (and *trigger-state-render*

   (fn [f]
     (fn []
       (this-as this
         (let [props (.. this -state -cljs$props)]
           (update-subscriptions this props props)
           (when f
             (f this
                props
                (.. this -state -cljs$state)
                (.. this -state -cljs$previousState)))))))

   "componentWillReceiveProps"
   (fn [f]
     (fn [next-props]
       (this-as this
         (let [next-props (expand-props this (parse-props next-props))
               prev-props (.. this -state -cljs$props)]
           (doto (.-state this)
             (gobj/set "cljs$previousProps" prev-props)
             (gobj/set "cljs$props" next-props))
           (binding [*trigger-state-render* false
                     *use-prior-props* true]
             (update-subscriptions this prev-props next-props)
             (when f (f this prev-props next-props)))))))

   "shouldComponentUpdate"
   (fn [f]

  ([this] (render-component this (props this)))
  ([this props] (render-component this props nil))
  ([this props & children]
    ;; manually invoke componentWillReceiveProps
   (when-let [will-receive-props (.-componentWillReceiveProps this)]
     (.call will-receive-props this #js {:cljs$props props
                                         :cljs$children children}))

    ;; only render if shouldComponentUpdate returns true (emulate ordinary React lifecycle)
   (when (.call (.-shouldComponentUpdate this) this props (state this))
     (force-update this))))

;; TODO - include render loop

