Make sure reactify-component always re-renders

It might get mutable data from js
This commit is contained in:
Dan Holmsand 2015-02-08 13:20:40 +01:00
parent e6c8639277
commit a29e0c75c7
1 changed files with 11 additions and 3 deletions

View File

@ -226,11 +226,19 @@
(into {} (for [k (js-keys o)]
[(keyword k) (aget o k)])))
(def elem-counter 0)
(defn reactify-component [comp]
(.' js/React createClass
#js{:displayName "react-wrapper"
:render
(fn []
(this-as
this (as-element
[comp (shallow-obj-to-map (.' this :props))])))}))
(this-as this
(as-element
[comp
(-> (.' this :props)
shallow-obj-to-map
;; ensure re-render, might get mutable js data
(assoc :-elem-count
(set! elem-counter
(inc elem-counter))))])))}))