.JSX worked on localhost but not on myapp.meteor.com


#1

I called .jsx code of React below in foo.html

<div>
{{> React component=UserAvatar userId=_id onClick=onClick}}
</div>

But it displayed nothing in online myapp.meteor.com, it displayed right userid and email in localhost:3000.
what could be wrong? Any right way to use callback functions?

in index.jsx.sml

var UserAvatar = React.createClass({
  mixins: [ReactMeteorData],
  getMeteorData() {
    return {
      currentUser: Meteor.user()
    };
  },
  render() {
    var curuser = this.data.currentUser;
    return <span>UserID: {curuser._id} Email: {curuser.emails}</span>;
  }
});

Template.simplereact.helpers({
  UserAvatar() {
    return UserAvatar;
  },
  onClick() {
    var self = Template.instance();

    return function () {
      self.hasBeenClicked.set(true)
    }
  }
});

#2

You should make sure it doesn’t render before Meteor.user() is defined. It was working on local probably because you had no latency lag.

if (curuser === null) {
    return null;
}

#3

Unfortunately this did not solve problem. There is no render at all. A bug of React?


#4

I had similar funny moment recently after realizing deploy DB is empty and there is nothing to show.