3 ms·
React dropping mixins is the #1 reason why I stopped using Meteor. Sure Meteor has Blaze, but nobody uses it. Before we had a nice mixin called getMeteorData:
by sergiotapia 10y ago
React dropping mixins is the #1 reason why I stopped using Meteor. Sure Meteor has Blaze, but nobody uses it.
Before we had a nice mixin called getMeteorData:
```
var HelloUser = React.createClass({
mixins: [ReactMeteorData],
getMeteorData() {
return {
currentUser: Meteor.user()
};
},
render() {
return <span>Hello {this.data.currentUser.username}!</span>;
}
});
```
Short, simple, you knew exactly what it was doing without breaking your wrists.
Now it's some create container lunacy that brings no benefit to most projects except dogma "properness" - the developer UX is just fungled beyond belief and it makes me so sad that Meteor lost so much.
I guess my gripe in general with Javascript now is how complicated simple things are. It's entire ecosystem is intertwined with complexity and verbosity.
I wonder if typescript alleviates some of these pain points.
- bcherny 10y ago> I wonder if typescript alleviates some of these pain points. TS :> JS, not <:. What specifically are you hoping TS addresses?
- tlrobinson 10y agoI 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?