Problem on Template and React


#1

I am trying a simplest react example as below. The problem is that the page only displayed “Hello !” without Meteor.user name displayed although I have login to a user. Is it a problem that I can not add npm-container package?

In .html file

<template name='simplereact'>
  <head>
    <title>Simple React</title>
  </head>
  <div>{{> loginButtons}}</div>
  <div>{{> React component=UserAvatar userId=_id onClick=onClick}}</div>
</template>

in .jsx file

var UserAvatar = React.createClass({
  mixins: [ReactMeteorData],
  getMeteorData() {
    return {
      currentUser: Meteor.user()
    };
  },
  render() {
    return <h2>Hello {this.data.currentUser.username} !</h2>;
  }
});

Template.simplereact.helpers({
  UserAvatar() {
    return UserAvatar;
  },

  onClick() {
    var self = Template.instance();

    // Return a function from this helper, where the template instance is in
    // a closure
    return function () {
      self.hasBeenClicked.set(true)
    }
  }
});