Created
March 11, 2015 10:52
-
-
Save gaearon/b0c060edf413fe23db0a to your computer and use it in GitHub Desktop.
Functional “component wrapper” API. A variation on https://github.com/acdlite/flummox/blob/master/docs/why-flux-component-is-better-than-flux-mixin.md
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
let BlogPostPage = React.createClass({ | |
render() { | |
<div> | |
<SiteNavigation /> | |
<MainContentArea> | |
{connectToStores({ | |
posts: store => ({ | |
post: store.getPost(this.props.postId), | |
nextPost: store.getPostAfter(this.props.postId) | |
}) | |
}, ({ post }) => { | |
{/* | |
THE FUN PART! I can use this state however I want, even with multiple or nested elements. | |
Everything is explicit. | |
*/} | |
<div> | |
<BlogPost post={post} /> | |
<NextPost post={nextPost} /> | |
</div> | |
})} | |
</MainContentArea> | |
<SiteSidebar /> | |
<SiteFooter /> | |
</div> | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Track progress here: acdlite/flummox#77