Skip to content

Instantly share code, notes, and snippets.

@sohalloran
Created June 9, 2016 10:12
Show Gist options
  • Save sohalloran/554d11bf001fcfbdf901540f45872f33 to your computer and use it in GitHub Desktop.
Save sohalloran/554d11bf001fcfbdf901540f45872f33 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="React by Example - Components">
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="http://fb.me/react-with-addons-0.14.3.js"></script>
<script src="http://fb.me/react-dom-0.14.3.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JSX in Detail</title>
</head>
<body>
<div id="container">
</div>
<script id="jsbin-javascript">
var Heading = React.createClass({displayName: 'Heading',
render: function() {
return (React.createElement("th", null, this.props.heading));
}
});
var Row = React.createClass({displayName: 'Row',
render: function() {
return (React.createElement("tr", null,
React.createElement("td", null, this.props.row.when),
React.createElement("td", null, this.props.row.who),
React.createElement("td", null, this.props.row.description)
));
}
});
var Headings = React.createClass({displayName: 'Headings',
render: function() {
var headings = this.props.headings.map(function(heading){
return (React.createElement(Heading, {heading: heading}));
});
return (React.createElement("thead", null, React.createElement("tr", null, headings)));
}
});
var Rows = React.createClass({displayName: 'Rows',
render: function() {
var rows = this.props.rows.map(function(row){
return (React.createElement(Row, {row: row}));
});
return (React.createElement("tbody", null, rows));
}
});
var App = React.createClass({displayName: 'App',
render: function(){
return React.createElement("table", {className: "table"},
React.createElement(Headings, {headings: this.props.headings}),
React.createElement(Rows, {rows: this.props.rows})
);
}
});
var data = [{ "when": "2 minutes ago",
"who": "Jill Dupre",
"description": "Created new account"
},
{
"when": "1 hour ago",
"who": "Lose White",
"description": "Added fist chapter"
}, {
"when": "2 hours ago",
"who": "Jordan Whash",
"description": "Created new account"
}];
var headings = ['When','Who','Description'];
var title = 'Recent Changes';
ReactDOM.render(React.createElement(App, {headings: headings, rows: data}), document.getElementById('container'));
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<meta name="description" content="React by Example - Components">
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"><\/script>
<script src="//fb.me/react-with-addons-0.14.3.js"><\/script>
<script src="//fb.me/react-dom-0.14.3.js"><\/script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JSX in Detail</title>
</head>
<body>
<div id="container">
</div>
</body>
</html></script>
<script id="jsbin-source-javascript" type="text/javascript"> var Heading = React.createClass({
render: function() {
return (<th>{this.props.heading}</th>);
}
});
var Row = React.createClass({
render: function() {
return (<tr>
<td>{this.props.row.when}</td>
<td>{this.props.row.who}</td>
<td>{this.props.row.description}</td>
</tr>);
}
});
var Headings = React.createClass({
render: function() {
var headings = this.props.headings.map(function(heading){
return (<Heading heading={heading}/>);
});
return (<thead><tr>{headings}</tr></thead>);
}
});
var Rows = React.createClass({
render: function() {
var rows = this.props.rows.map(function(row){
return (<Row row={row}/>);
});
return (<tbody>{rows}</tbody>);
}
});
var App = React.createClass({
render: function(){
return <table className = 'table'>
<Headings headings={this.props.headings} />
<Rows rows={this.props.rows} />
</table>;
}
});
var data = [{ "when": "2 minutes ago",
"who": "Jill Dupre",
"description": "Created new account"
},
{
"when": "1 hour ago",
"who": "Lose White",
"description": "Added fist chapter"
}, {
"when": "2 hours ago",
"who": "Jordan Whash",
"description": "Created new account"
}];
var headings = ['When','Who','Description'];
var title = 'Recent Changes';
ReactDOM.render(<App headings={headings} rows={data}/>, document.getElementById('container'));
</script></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment