Skip to content

Instantly share code, notes, and snippets.

@areina
Last active September 24, 2015 09:38
Show Gist options
  • Save areina/b7df181ca2f17671f300 to your computer and use it in GitHub Desktop.
Save areina/b7df181ca2f17671f300 to your computer and use it in GitHub Desktop.
(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