Thanks for the explanation, though I’m still not certain what the implications are between how react-meteor-data & tracker-react passes data around versus how react-komposer does.
–Why does it matter that react-meteor-data & tracker-react pass data in at the component level as opposed to react-komposer which passes in data via props?
Regardless, according to casperandersen’s reply, it would seem that using react-komposer might be the best approach as he stated that React has deprecated mixins (is this accurate?).
I’ve been curious on how this will work for developers trying to use only ES6? Will Meteor have an ES6 way of dealing with meteor data? What we do at the company I work for is have a base Component = React.createClass({mixins:[ReactMeteorData]}) and then we inherit from it for all of the rest of our components using Subcomponent = class extends Component() which seems a little hacky but we haven’t come up with a better solution yet.
I guess outside of what the general “best practices” are, my personal view is that I would much rather be able to add functionality to a component rather than introducing a new wrapper for every single function. It’s great that ES2015 has inheritance, but “inheritance is not for sharing code” - you can only inherit from one class at a time.
I have been using the react-mixin npm package to enable reactivity with components that I write with ES6 (class Name extends React.Component), and its really easy too. For instance, If you have a component Main: ReactMixin(Main.prototype, ReactMeteorData); and the mixin works (at least for me so far).
However, I am aware that this is no longer best practices, so I’m interested in updating my code sooner than later. I’m just unsure really what the difference is between using React.createClass{()} and class Name extends React.Component.
in the “I like mixins” reasons for the React.createClass factory pattern, it refers to react-router, however that is no longer current. The mixins approach is now deprecated with react-router
Composition. “Higher-Order-Component will work with both kinds of classes, and will be forward compatible with pure functions.”
I think that React will rid of these pseudo Classes sooner or later This is quite weird that React plays functional approach and here we get pseudo OO Classes. Even now, we have stateless function components.
Just an opinion.
For me Arunoda’s react-komposer is very interesting. I would like to read more about it and see more examples in demo apps. There will be also Mantra which will use this approach so it could be nice.
Yeah but the function components are bit janky for my taste - what about prop types, component names, etc? Perhaps decorators and similar will come to the rescue.
The mantra setup is actually really, really good. The function components are the proper use of the new recommended stateless/‘dumb’ components. component name is the name of the function. ‘smart’ components do have component names and props, but I do think correct prop type definitions need to be added to improve the examples.
That’s weird because we use the same babel transform, AFAIK… perhaps it will be better in Meteor 1.3, when we are unifying the ecmascript and jsx packages… @benjamn?
I guess one of my favorite things about React initially was OOP-style components, but I can see the benefit of a functional style as well.
Automatic displayName used to not work in the first Meteor + React implementation, and this was eventually fixed/added. So I’m assuming this is in fact a bug or needs implementation and will be added, so .displayName will just be temporary.
Thanks, rhywden. I must have missed where this was stated on their github.
Would you please provide a link citing this update so I can remove the step from the guide?
We just released an easy React and Tracker integration, one can not make this easier and the implementation can’t be lighter, it’s ridiculous how easy we’ve made it.
Bonus feature: Server Side Rendering (see the clip ;))
Learn how we build easy React Components with Meteor 1.2 and Tracker using Tracker.Component: