Skip to content

Instantly share code, notes, and snippets.

@edbond
Created August 29, 2015 21:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edbond/7d7a9d86affd16f8d943 to your computer and use it in GitHub Desktop.
Save edbond/7d7a9d86affd16f8d943 to your computer and use it in GitHub Desktop.
Render React component from Om
(ns nhchat.components.comment
(:require [om.core :as om]
[om-tools.core :refer-macros [defcomponent]]
[sablono.core :refer-macros (html)]))
(enable-console-print!)
(defcomponent wrapper [{:keys [comment]} owner]
(render [_]
(html [:div]))
(did-mount [_]
(let [node (om/get-node owner)
el (.createElement js/React js/CommentBox #js {:comment comment})]
(.render js/React el node))))
(om/root wrapper {:comment "Hello, react!"}
{:target (.getElementById js/document "app")})
<script src="https://fb.me/react-0.13.3.min.js"></script>
<script type="text/javascript">
var CommentBox = React.createClass({displayName: 'CommentBox',
render: function() {
return (
React.createElement('div', {className: "commentBox"},
this.props.comment
)
);
}
});
</script>
<script type="text/javascript" src="js/dev/cljs-output.js"></script>
<div id="app"><div data-reactid=".0"><div class="commentBox" data-reactid=".1">Hello, react!</div></div></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment