-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve HoC connectToStores Docs #136
Comments
Yes to all, that would be a huge help |
just checking: right now the HoC needs a higher FlummoxComponent to pass the flux object to the context right?. or is there a way to pass the flux object to the HoC? |
Correct, currently no way to pass Flux directly to the HoC |
Slightly unrelated: are there plans to add this behavior to the HoC?, should I open an issue? |
Yeah, eventually. Also want to add |
been working on the docs!. Quickstart and React integration are ready. i'll be doing "Why HoC > FluxComponent > fluxMixin" next week! |
👍 Documentation on what Once i hit the point (a very lucky shot) where "it works but i do not know why" i figured out what did what by intentionally breaking stuff, but its not exactly evident. And i was not even aware that HoC != FluxComponent. |
👍 |
Thanks a lot for these docs @burabure ! It helped me a loooot.
Depends on your module loading system, if you're using io.js, I think it could be helpful for those like me to include this point in the documentation. Thoughts ? |
thanks @akofman, happy to help =) about the issue: I think you're right. with ES6 arrow functions i'll fix it right away! |
Store state getters are not bound to the component instance, as of v3.0, so even without an arrow function, // Pass an object of store keys mapped to getter functions
MyComponent = connectToStores(MyComponent, {
posts: (store, props) => ({
postBody: store.getPostBody(props.post.id),
}),
comments: (store, props) => ({
comments: store.getCommentsForPost(props.post.id),
})
}); |
Oops, I hate that button :D |
thank you @acdlite. is that behaviour documented?, I think there's something about them in the upgrade guide, but it seems everything else is outdated. I'll add it to the component, HoC and mixin just in case =) |
I don't think it's explicitly documented anywhere, just reflected in the examples. Thanks :) |
just checking: also, i think class BlogPostPage extends React.Component {
render() {
<div>
<SiteNavigation />
<MainContentArea>
<FluxComponent connectToStores={{
posts: store => ({
post: store.getPost(this.props.postId),
})
}}>
<BlogPost />
</FluxComponent>
</MainContentArea>
<SiteSidebar />
<SiteFooter />
</div>
}
} |
In that case it refers to the props of the owner (BlogPostPage), which is probably what you want. Double wrapping is correct because you're passing an object. The first set of braces is for embedding a JavaScript value in JSX; the second set is the object itself. It's the same concept as when you pass an inline object to the |
stateGetter's second param (props) in the docs now. @acdlite if you have a couple minutes for a quick check, in case I messed up some detail, it would be awesome =) |
typo fixed and proof read. ready to pull in =) |
Thanks! I'll try to get this merged in tonight. Sorry I've been a bit less responsive lately — I accepted a new job in a new city, so I've been really busy :) |
hope the new job and the moving stuff are getting less crazy ;D Let me know if I can help with anything to make this PR easier to pull |
@acdlite we should get this merged I think :) |
+1 this would be helpful to have merged. I cloned vesparny's repo and it uses the HoC, and with no documentation it was pretty confusing. |
+1 |
While the function itself is anonymous - now that |
I think that the connectToStores HoC pattern is a huge plus for Flummox, and that the actual docs don't showcase how awesome it is (Easy, intuitive Relay-like data fetching from stores).
I'd be happy to send a PR with an updated Quick start, examples and a "Why HoC > FluxComponent > fluxMixin". Also I could introduce
because without it HoC becomes very clunky.
@acdlite basically I just want to check if this is the direction that you want on the guide/docs?
The text was updated successfully, but these errors were encountered: