@sashko Your method did worked; with more code but a user could not clear the field. This made me invested more about Meteor and I’ve found Meteor.autorun.
I had to change my original code from:
To:
Meteor.publish("userData", function () {
...
I needed to add the subscription to FlowRouter:
FlowRouter.route('/profile', {
name: 'profile',
action(){
var subs = Meteor.subscribe('userData');
Meteor.autorun(function() {
if (subs.ready()) {
ReactLayout.render(App, {
nav: <Nav />,
content: <Profile user={ Meteor.user() }/> // passing the props to getInitialState()
});
}
});
}
});
Now my getInitialState() looks like this:
...
fname: this.props.user.profile.firstName,
...
formSubmit() {
let fname = this.state.fname;
let students = {
firstName: fname,
...
};
Meteor.users.update( { _id: Meteor.userId() }, {
$set: {profile: students}
});
},
My render():
<input type="text value={this.state.fname} onClick={this.formSubmit} placeholder="First name" />
Bam! Two-way binding at its best with Meteor and React! Works fast across FF, Safari and Chrome.
Credit to this goes to @Steve