While talking with @joshowens the other day he pointed out that there are now many different approaches to data loading in React. So I thought I’d write up a quick comparison of four techniques:
I think that I disagree about TrackerReact, I find it to be much more transparent and easy to build smart containers and pass props down to dumb components easily. I don’t really think the pattern is easier or harder because of TrackerReact. I think it is much more clear how it all works when you build one, though.
Sadly, the recent class I gave covered React Komposer and Tracker React, but not the React List container. I should try it soon for comparison.
As an addition to comparing all these 4 techniques, when you’re using MDG wrapper or React Komposer, it’s easy to switch from one tool to another and it’s more react reusable components approach.
That article talks about creating a ListsShowPage using createComponent and then using it via <ListsShowPage params={{id: '7'}}/>. But where is ListsShowPage defined? (createComponent doesn’t have/use ListsShowPage)
Lets imagine that it was list-show-page.js. Then anywhere else you can import and use it
import ListsShowPage from './list-show-page.js'
// note we use export default there. So it is no matter how to name it
// when importing
// if you like you may import it with any other name like
// import MySuperContainer from './list-show-page.js'
render(<ListsShowPage params={{id: '7'}}/>, document.body);
It’s not clear to me, are they going to update the docs from the todos example (which doesn’t even reference createComponent) or the example from the docs?
That’s how you reference ListsShowPage, I want to know how it’s defined. In your example it’s the contents of list-show-page.js. The docs have the following which doesn’t mention ListsShowPage:
I guess if we use export default we need to indicate the filename somehow in the guide.
I can see the confusion here but I’m still feeling like if the file is called ListsShowPage.jsx and then exports ListShowPage it feels a little redundant.
Anyway, I can see the arguments both ways, I think for this React stuff we should just do whatever the React examples do when they switch to ES2015 modules (they still use require at this point which is closer to export default)
I like this a lot! This seems to strike a good balance between clear naming and the default export. And if someone’s an expert in ES2015 they’ll know that the intermediate variable can be omitted.