Alanning roles in React

UserList = React.createClass({
  mixins: [ReactMeteorData],
  getMeteorData() {
    return {
     users: Meteor.users.find({}).fetch(),
     loggedIn: !!Meteor.user()
    renderRole() {
        if(Roles.userIsInRole(loggedIn, 'admin')){
          return (

This results in a blank page. I’m not sure how to handle my template logic, or should I handle it all on the pub/sub level?

did you check the console? it looks like loggedIn is not in scope so it should be undefined. Using if(Roles.userIsInRole(Meteor.userId(), 'admin')) might work though.

if(Roles.userIsInRole(, 'admin')) , does this works?

1 Like

Not sure why, but replacing !!Meteor.user() with Meteor.user() and using worked for me.

Why is this?

I’m also learning meteor-react, I just started few days back so I’m in no way expert in this.

As mentioned here in meteor tutorial

If you want to access the data returned from getMeteorData() you should use in other methods.

Please read that tutorial for more Info.


!! will coerce the expression after it into a boolean, the first ! negates it (making it false and doing it again negates the first negate making it true). So essentially you’re passing true/false into the function instead of the user object.