Last active
September 24, 2015 09:38
-
-
Save areina/b7df181ca2f17671f300 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn foo-root [component] | |
(fn [data _owner] | |
(reify | |
om/IRender | |
(render [_] | |
(let [ctor (js/React.createFactory | |
(js/React.createClass | |
#js | |
{ | |
:getDisplayName (fn [] "muiroot-context") | |
:childContextTypes #js {:muiTheme js/React.PropTypes.object} | |
:getChildContext (fn [] #js {:muiTheme *mui-theme*}) | |
:render (fn [] (component data))}))] | |
(ctor. nil)))))) | |
(defn foo [data owner] | |
(reify | |
om/IInitState | |
(init-state [_] | |
{:value "FOO"}) | |
om/IRenderState | |
(render-state [_ state] | |
(dom/div nil | |
(dom/div nil (:value state)) | |
(dom/button #js {:onClick #(om/set-state! owner :value "BAR")} "change"))))) | |
(defn main [] | |
(om/root (foo-root (fn [cursor x] | |
(om/build foo cursor))) app-state {:target (. js/document (getElementById "app"))})) | |
;; (defn main [] | |
;; (om/root foo app-state {:target (. js/document (getElementById "app"))})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment