Skip to content

Instantly share code, notes, and snippets.

@AGresvig
Created Jul 31, 2014
Embed
What would you like to do?
var React = require('react');
module.exports = React.createClass({
render: function() {
return (
<div className="post">
<h2 className="postName">
ssdfsdf
{this.props.title}
</h2>
{this.props.children}
</div>
);
}
});
var React = require('react');
var PostHandler = module.exports = React.createClass({
render: function() {
return (
<div>
<h2>Post Section</h2>
<this.props.activeRouteHandler />
</div>
);
}
});
var React = require('react');
var Post = require("./post.jsx");
var posts = [
{
slugId: "post-one",
title: "Post One",
text: "Hey there this is post One!"
}, {
slugId: "post-two",
title: "Post two",
text: "Hey there this is post TWO ok!"
}
];
module.exports = React.createClass({
getInitialState: function(cb) {
return {posts: posts};
},
render: function() {
var postNodes =
this.state.posts.map(function(post) {
return <Post title={post.title}>{post.text}</Post>;
});
return (
<div>
<h2>Posts</h2>
<div className="postList">
{postNodes}
</div>
</div>
);
}
});
<Routes>
<Route handler={App}>
<Route handler={PostHandler}>
<Route name="posts" handler={PostList}/>
<Route name="post" path="/post/:slugId" handler={Post}/>
</Route>
<Route name="about" handler={About}/>
</Route>
</Routes>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment