How to apply Tracker.autorun? Meteor.userId() undefined right after refreshing page
问题 I have a restricted page using Meteor.userId() and roles: class AdminPage extends Component { render() { return ( <div> { Roles.userIsInRole(Meteor.userId(), 'admin') ? ( <Master_Layout renderCenter={<Article_Editor />}/> ) : browserHistory.push('/') } </div> ) } } This code redirects user to "/" after refresh because Meteor.userId() is undefined. How do I make sure Meteor.userId() is not undefined before rendering the page after refresh? I searched for answers. I found Tracker.autorun as a