Facebook comments only show sometimes


#1

I’m using the Facebook SDK package http://fastosphere.meteor.com/biasport%3Afacebook-sdk?q=facebook%20

I want to load comments on my page, but they only show up sometimes. The comments show up and work fine when you reload the page/type the url in manually and press enter. But, when you enter the page from a link on a previous page, the comments don’t show up. They show up again when you reload it.

Using React, Flow Router, Kadira:react-layout.

Edited: showing my code now

Comments.jsx

window.fbAsyncInit = function() {
  FB.init({
    appId      : '123456',
    status     : true,
    xfbml      : true,
    version: "v2.5"
  });
};

Comments = React.createClass({
  render() {
    return (
      <div>
        <div
          className="fb-comments"
          data-href="http://www.mysite.com/video/wqYhkbTrFNSS6f9PZ"
          data-width="100%"
          data-colorscheme="light"
          data-numposts="5"></div>
      </div>
    );
  }
});

VideoPage.jsx

...
return (
      <div>
        <div className="container">
          <div className="row centered">
            <div className="col-md-8">
              {this.renderVideo()}
              <div className="hidden-sm hidden-xs">
                <Comments />
              </div>
            </div>
            <div className="col-md-4 hidden-sm hidden-xs">
              {this.renderSuggested()}
            </div>
            <div className="col-md-12 visible-sm visible-xs">
              {this.renderMobileBottomContent()}
            </div>
          </div>
        </div>
      </div>
    );

#2

well, maybe if you paste actual code…


#3

Showing some actual code now.


#4

I dont see where you call FB.XFBML.parse();
What could explain why you only see it once - when the page is rendered before FB SDK is loaded.


#5

Hmm where am I supposed to be calling that? I thought that was only for Iron Router, but I can give it a shot. Does it go in the componentDidMount()?


#6

onRendered in Blaze, in React you should know :smiley:


#7

It worked! I put it in componentDidMount(). Thanks a lot! This was killing me the past few days.