Skip to content

Instantly share code, notes, and snippets.

@supnate
Created September 11, 2014 03:47
Show Gist options
  • Save supnate/ec7a56f689b73c409fba to your computer and use it in GitHub Desktop.
Save supnate/ec7a56f689b73c409fba to your computer and use it in GitHub Desktop.
[add your bin description] // source http://jsbin.com/fubuza/9
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://fb.me/react-0.11.0.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id="content">123</div>
<script id="jsbin-javascript">
/** @jsx React.DOM */
var CommentList = React.createClass({displayName: 'CommentList',
render: function() {
var commentNodes = this.props.data.map(function (comment) {
return (
Comment({author: comment.author, children: "abc"},
comment.text
)
);
});
return (
React.DOM.div({className: "commentList"},
commentNodes
)
);
}
});
var Comment = React.createClass({displayName: 'Comment',
render: function() {
return (
React.DOM.div({className: "comment"},
React.DOM.h2({className: "commentAuthor"},
this.props.author
),
this.props.children
)
);
}
});
var data = [
{"author": "Pete Hunt", "text": "This is one comment"},
{"author": "Jordan Walke", "text": "This is *another* comment"}
];
React.renderComponent(
CommentList({data: data}),
document.getElementById('content')
);
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<script src="//code.jquery.com/jquery-2.1.1.min.js"><\/script>
<script src="//fb.me/react-0.11.0.js"><\/script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id="content">123</div>
</body>
</html></script>
<script id="jsbin-source-javascript" type="text/javascript">/** @jsx React.DOM */
var CommentList = React.createClass({
render: function() {
var commentNodes = this.props.data.map(function (comment) {
return (
<Comment author={comment.author} children="abc">
{comment.text}
</Comment>
);
});
return (
<div className="commentList">
{commentNodes}
</div>
);
}
});
var Comment = React.createClass({
render: function() {
return (
<div className="comment">
<h2 className="commentAuthor">
{this.props.author}
</h2>
{this.props.children}
</div>
);
}
});
var data = [
{"author": "Pete Hunt", "text": "This is one comment"},
{"author": "Jordan Walke", "text": "This is *another* comment"}
];
React.renderComponent(
<CommentList data={data} />,
document.getElementById('content')
);</script></body>
</html>
/** @jsx React.DOM */
var CommentList = React.createClass({displayName: 'CommentList',
render: function() {
var commentNodes = this.props.data.map(function (comment) {
return (
Comment({author: comment.author, children: "abc"},
comment.text
)
);
});
return (
React.DOM.div({className: "commentList"},
commentNodes
)
);
}
});
var Comment = React.createClass({displayName: 'Comment',
render: function() {
return (
React.DOM.div({className: "comment"},
React.DOM.h2({className: "commentAuthor"},
this.props.author
),
this.props.children
)
);
}
});
var data = [
{"author": "Pete Hunt", "text": "This is one comment"},
{"author": "Jordan Walke", "text": "This is *another* comment"}
];
React.renderComponent(
CommentList({data: data}),
document.getElementById('content')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment