server side code
Meteor.methods({
'users.profileUpdate'(profileData){
isValid = ProfileSchema.namedContext("myContext").validate(profileData);
if(! this.userId){
throw new Meteor.Error('not-authorized');
}
if(isValid){
Meteor.users.update({_id:this.userId}, {
$set: {
profile: profileData
}
});
}
},
})
client side code
export default class Profile extends Component{
constructor() {
super();
this.state = {
subscription: {
users: Meteor.subscribe('users')
}
}
}
componentWillUnmount() {
this.state.subscription.users.stop();
}
render(){
return(
<div className="row">
<div className="container">
{this.props.user ?
<header>
<div>
<h3>User Profile</h3>
</div>
<div className="profilePic">
<img src={"/images/"+this.props.user._id+'.png'} alt="user" />
</div>
<h1>Username: {this.props.user.username}</h1>
<h2>Email Id: {this.props.user.address}</h2>
{this.props.user.profile ?
<div className="profileInfo">
<h3>First Name: {this.props.user.profile.first_Name}</h3>
<h3>Last Name: {this.props.user.profile.last_Name}</h3>
<h3>Phone No: {this.props.user.profile.phonNo}</h3>
<h3>City: {this.props.user.profile.city}</h3>
<h3>Country: {this.props.user.profile.country}</h3>
</div>
:
<div className="profileInfo">
<h3>First Name: </h3>
<h3>Last Name: </h3>
<h3>Phone No: </h3>
<h3>City: </h3>
<h3>Country: </h3>
</div>
}
</header>
:
''
}
</div>
</div>
)
}
}
export default createContainer(() => {
if(Meteor.users.findOne({username:FlowRouter.getParam("profileName")}) != undefined){
return {
user: Meteor.users.findOne({username:FlowRouter.getParam("profileName")}),
currentUser: Meteor.user()
}
}
}, Profile);
Everything works fine when navigated through links on the page but whenever the profile page gets reloaded this error pops.
Uncaught TypeError: Cannot convert undefined or null to objectkeys @ es5-shim.js:1103calculateData @ ReactMeteorData.jsx:111componentWillMount @ ReactMeteorData.jsx:5(anonymous function) @ ReactCompositeComponent.js:347measureLifeCyclePerf @ ReactCompositeComponent.js:74performInitialMount @ ReactCompositeComponent.js:346mountComponent @ ReactCompositeComponent.js:257mountComponent @ ReactReconciler.js:47mountChildren @ ReactMultiChild.js:240_createInitialChildren @ ReactDOMComponent.js:699mountComponent @ ReactDOMComponent.js:524mountComponent @ ReactReconciler.js:47mountChildren @ ReactMultiChild.js:240_createInitialChildren @ ReactDOMComponent.js:699mountComponent @ ReactDOMComponent.js:524mountComponent @ ReactReconciler.js:47performInitialMount @ ReactCompositeComponent.js:370mountComponent @ ReactCompositeComponent.js:257mountComponent @ ReactReconciler.js:47performInitialMount @ ReactCompositeComponent.js:370mountComponent @ ReactCompositeComponent.js:257mountComponent @ ReactReconciler.js:47mountComponentIntoNode @ ReactMount.js:105perform @ Transaction.js:138batchedMountComponentIntoNode @ ReactMount.js:127perform @ Transaction.js:138batchedUpdates @ ReactDefaultBatchingStrategy.js:63batchedUpdates @ ReactUpdates.js:98_renderNewRootComponent @ ReactMount.js:321_renderSubtreeIntoContainer @ ReactMount.js:402render @ ReactMount.js:423(anonymous function) @ client.js:62
debug.js:41 Exception from Tracker recompute function:
debug.js:41 TypeError: Cannot read property '_currentElement' of null
at ReactCompositeComponentWrapper._updateRenderedComponent (ReactCompositeComponent.js:742)
at ReactCompositeComponentWrapper._performComponentUpdate (ReactCompositeComponent.js:721)
at ReactCompositeComponentWrapper.updateComponent (ReactCompositeComponent.js:642)
at ReactCompositeComponentWrapper.performUpdateIfNecessary (ReactCompositeComponent.js:558)
at Object.performUpdateIfNecessary (ReactReconciler.js:158)
at runBatchedUpdates (ReactUpdates.js:151)
at ReactReconcileTransaction.perform (Transaction.js:138)
at ReactUpdatesFlushTransaction.perform (Transaction.js:138)
at ReactUpdatesFlushTransaction.perform (ReactUpdates.js:90)
at Object.flushBatchedUpdates (ReactUpdates.js:173)
debug.js:41 Exception from Tracker recompute function:
debug.js:41 TypeError: Cannot read property '_currentElement' of null
at ReactCompositeComponentWrapper._updateRenderedComponent (ReactCompositeComponent.js:742)
at ReactCompositeComponentWrapper._performComponentUpdate (ReactCompositeComponent.js:721)
at ReactCompositeComponentWrapper.updateComponent (ReactCompositeComponent.js:642)
at ReactCompositeComponentWrapper.performUpdateIfNecessary (ReactCompositeComponent.js:558)
at Object.performUpdateIfNecessary (ReactReconciler.js:158)
at runBatchedUpdates (ReactUpdates.js:151)
at ReactReconcileTransaction.perform (Transaction.js:138)
at ReactUpdatesFlushTransaction.perform (Transaction.js:138)
at ReactUpdatesFlushTransaction.perform (ReactUpdates.js:90)
at Object.flushBatchedUpdates (ReactUpdates.js:173)
148ReactDOMComponentTree.js:107 Uncaught TypeError: Cannot read property '__reactInternalInstance$e1l06bgkqvy3bohv5g41v2t9' of null
Unable to find what gives this error. I went through many similar errors on stack overflow but wasn't able to find any solution regarding this problem. Any help would be appreciated.
Make sure you are returning an object from the 'createContainer' as a minimum:
export default TestContainer = createContainer(({ params }) => {return {}}, Test);
export default TestContainer = createContainer(({ params }) => new Object, Test);