4 ms·
I was going to sketch out a higher order component for you that does the same thing but it looks like they've already implemented that: https://atmospherejs.com
by tlrobinson 10y ago
I was going to sketch out a higher order component for you that does the same thing but it looks like they've already implemented that: https://atmospherejs.com/meteor/react-meteor-data https://atmospherejs.com/meteor/react-meteor-data
I guess this is the "create container lunacy" you're talking about?
I'm not sure what's so horrible about it, especially if you enable decorators in Babel (admittedly non-standard syntax but it works great):
@createContainer(() => ({
currentUser: Meteor.user()
}))
export default class Foo extends Component {
return <span>Hello {this.props.data.currentUser.username}!</span>;
}
This is basically how Redux's React bindings works too.
Is it really just the syntax you're upset about, or am I missing something?
- danabramov 10y agoYou don’t even need that syntax. (Please don’t use decorators in examples, they are not part of the language yet. This is super confusing.) function Foo(props) { return <span>Hello {props.data.currentUser.username}!</span>; } function getMeteorData() { return { currentUser: Meteor.user() }; } export default createContainer(getMeteorData)(Foo) Why do you see this as “lunacy” compared to mixins?