In my react.js app I have this array in state:
constructor(props) {
super(props);
this.state = {
userRecord: {
userName: '',
userEmail: '',
userAge: '',
userHeight: '',
userRace: '',
userGender: '',
createdAt: undefined,
updatedAt: undefined
}
}
}
then I call a function where I'm trying to set the state of each value
this.setState({
userRecord.userName: newuserDocs[0].userName,
userRecord.userAge: newuserDocs[0].userAge,
userRecord.userHeight: newuserDocs[0].userHeight,
userRecord.userRace: newuserDocs[0]. userRace,
userRecord.userGender: newuserDocs[0].userGender,
userRecord.userEmail: newuserDocs[0].userEmail,
});
But I'm getting an error that the period between userRecord and each value is incorrect.
How do I properly set the state of those values?