Created
August 29, 2015 21:16
-
-
Save edbond/7d7a9d86affd16f8d943 to your computer and use it in GitHub Desktop.
Render React component from Om
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
(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")}) |
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
<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> |
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
<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