ReactJS: Reload component if variable changes value

Viewed 15862

In my main component <App /> of my meteorJS application I'm using some user data (const user = Meteor.user()). If the user-object has a check value <AnotherComponent /> will be used. There the user can do some interaction and the check field gets removed from user document.

To make it a bit clearer: The check value will be removed on another place by updating the value in the db.

Now I would expect, that now <MainComponent /> will be rendered. But it won't. I need to reload the page to get it.

Is there a way how I can make the user variable 'reactive'?

class App extends Component {
  render () {
    const user = Meteor.user()

    if (user && user.check) {
      return (<AnotherComponent />)
    }
    return (<MainComponent />)
  }
}
2 Answers
Related