Skip to content

Instantly share code, notes, and snippets.

@nonsensery
Created April 7, 2015 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nonsensery/11aa5a372f6f052a330d to your computer and use it in GitHub Desktop.
Save nonsensery/11aa5a372f6f052a330d to your computer and use it in GitHub Desktop.
React Component Experiments
class Post extends React.Component {
render() {
return (
<article>
<h2>{this.props.title}</h2>
<section>{this.props.children}</section>
</article>
);
}
}
// Don't do this, BTW.
new Post({}).render();
// => ReactElement { type: "article", … }
class MyApp extends React.Component {
render() {
return (
<div>
<h1>My Cool App</h1>
<Post title="Welcome">
<p>Hello There!</p>
</Post>
</div>
);
}
}
// Don't do this either, FYI.
new MyApp().render().props.children[1];
// => ReactElement { type: function Post(…) {}, … }