I’m trying to get my feet wet using React with Meteor and I keep stumbling into road blocks. It’s getting discouraging.
My latest was my attempt to create allow the user to edit their profile. I can’t seem to wrap my head around how getMeteorData works with state. I load the user data with getMeteorData, I can fill my form fields with it, however I’m not sure how to deal with the onChange handler (i called it changeHandler in the code) to update the field. So I can select my field boxes but I can’t see any updates or changes.
Can someone help me out?
getMeteorData() {
let handle = Meteor.subscribe("userData");
let userData = {};
if (handle.ready()) {
return {
userData: Meteor.user()
};
}
},
changeHandler(e) {
},
render() {
console.log(this.data.userData);
return(
<div className="page-body">
<div className="ui middle aligned center aligned grid">
<div className="column modal-small">
<h2 className="ui teal image header">
<div className="content">
Edit Profile
</div>
</h2>
<form className="ui large form" onSubmit={this.onSubmitForm}>
<div className="ui stacked segment">
<div className="field">
<label>Email Address</label>
<input type="text" name="email" value={this.data.userData.email} onChange={this.changeHandler} />
</div>
<div className="field">
<label>First Name</label>
<input type="text" name="firstName" value="" onChange={this.data.userData.profile.firstName} />
</div>
<div className="field">
<label>Last Name</label>
<input type="text" name="lastName" value="" onChange={this.data.userData.profile.lastName} />
</div>
<input type="submit" className="ui fluid large teal submit button" value="Update" />
</div>
</form>
</div>
</div>
</div>
)
}