react-facebook icon indicating copy to clipboard operation
react-facebook copied to clipboard

Comment - able to detect when comments are loaded

Open vt03 opened this issue 6 years ago • 3 comments

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.

vt03 avatar Apr 01 '19 01:04 vt03

+1 Also need this

kkomelin avatar Apr 10 '19 13:04 kkomelin

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 avatar Apr 10 '19 13:04 kkomelin

@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.

kkomelin avatar Apr 10 '19 14:04 kkomelin