3 ms·
In the example you used you're re-defining the class by wrapping it, not creating a global variable... Consider it like: var a = 1; a = func(a); Does it
by masterj 11y ago
In the example you used you're re-defining the class by wrapping it, not creating a global variable...
Consider it like:
var a = 1;
a = func(a);
Does it seem cleaner if you use the stateless functions from React 0.14? http://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components http://facebook.github.io/react/blog/2015/09/10/react-v0.14-...
var Score = (props) => (
<li key={props.score.initials}>
<strong>{props.score.initials}</strong> {props.score.score}
</li>
);
Score = Relay.createContainer(Score, {
fragments: {
score: () => Relay.QL`
fragment on Score {
initials,
score,
}
`,
},
});
- 6t6t6 11y agoThank you very much for the explanation! I was confused because I didn't realize that, actually, a class in ES6 is just a variable. Also, I am not used to the decorator pattern. Now it makes sense.
- azernik 11y agoIt's even worse - classes in ES6 are just functions (their constructors); 'obj = new Class()' is just sugar for 'obj = {}; Class.bind(obj)()'. So if you leave off the "new", you'll end up clobbering whatever 'this' defaults to, which is usually the global window object.