seeden / react-facebook

Facebook components like a Login button, Like, Share, Chat, Comments, Page or Embedded Post
MIT License
790 stars 144 forks source link

Comment - able to detect when comments are loaded #129

Open vt03 opened 5 years ago

vt03 commented 5 years ago

When opening up the comments it takes a little while for it to load depending on the client's network speed (especially people still on 3g networks). It would be great if there was a place to specify a custom function to handle this loading so we can show a loading spinner or something else.

kkomelin commented 5 years ago

+1 Also need this

kkomelin commented 5 years ago

From Facebook documentation:

var finished_rendering = function() {
  console.log("finished rendering plugins");
}

// In your onload handler
FB.Event.subscribe('xfbml.render', finished_rendering);

https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v3.2

kkomelin commented 5 years ago

@vt03 I've just completed the task of displaying a progress indicator for FB Comments in React. You may check out the code here https://codesandbox.io/s/q8jxqw39w4 and its demo is here https://q8jxqw39w4.codesandbox.io/

Used a simple JS timer and React component lifecycle events.