Implementing Facebook comments plugin in ReactJS app

后端 未结 2 461
自闭症患者
自闭症患者 2021-02-07 20:43

I\'m trying to load the facebook comments plugin in a ReactJS app that\'s currently using React Router.

If I put the facebook init code inside my page\'s componentDidMou

2条回答
  •  天涯浪人
    2021-02-07 21:21

    You only need to initialize the JavaScript SDK once, and since componentDidMount only gets called once it´s fine where it is. Try putting FB.XFBML.parse() in componentDidUpdate:

    componentDidUpdate() {
        FB.XFBML.parse();
    }
    

    I am not sure if this is the best solution, but it should work.

提交回复
热议问题