meteor-mantra-kickstarter
meteor-mantra-kickstarter copied to clipboard
logout and tracker errors
Hi,
This isn't exactly related to what is currently in the repo, but as authentication and profile/accounts pages are partially implemented and stubbed out, this seems like it'll be relevant later.
I've been building out the profile page, but when a logout is triggered, just before the re-route, it raises Tracker recompute errors when the user data is suddenly missing.
Is there a graceful way of handling this, or is the only way to just null test the user record whereever it is used?
Thanks
Can you please provide some more details, error log?
The composers/account/profile.jsx
which I'm using to create a form the user can use to update their profile, uses this, which I modified from auth.jsx
:
if (Meteor.subscribe('users.current').ready()) {
const record = Meteor.users.findOne(Meteor.userId());
onData(null, {record, error, success});
}
If for example in the corresponding _form.jsx
, you have:
render() {
const {record, error, success} = this.props;
return (
<div>
{record.profile.firstName}
</div>
);
}
Navigating to /profile
will display the logged in user's first name.
If you click Logout in the menu, in the console you will see:
Exception from Tracker recompute function:
debug.js:41 TypeError: Cannot read property 'profile' of undefined
at render (_form.jsx:##)
Right before the logout action redirects to the public page.
I constantly run into this error, and as you suggest, usually just null test the meteor.id() before doing something that might result in an error. There must be a better way... @solace, do you remember what you did?