0
是否有另外一種寫作方式?順便說一句,這完美的作品,但我覺得它可以寫更好:使用反應和流星進行雙向數據綁定
Profile = React.createClass({
mixins: [ReactMeteorData],
getMeteorData() {
return {
currentUser: Meteor.user(),
};
},
getInitialState(){
// we add an if statement to prevent undefined errors
// could this be written elsewhere?
if (Meteor.user().profile) {
this.profile = Meteor.user().profile;
} else {
this.profile = '';
};
return { firstname: this.profile.firstname };
},
...
)};