How to integrate the Twitter widget into Reactjs?

前端 未结 9 2390
我在风中等你
我在风中等你 2021-02-18 20:33

I want to add the Twitter widget into React, but I don\'t know where to start or how to do it. I am very new to React JS.

Here is the HTML version of the code:

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-18 21:15

    It seems to be much easier to just use Twitter's widgets.js, more specifically createTimeline.

    class TwitterTimeline extends Component {
      componentDidMount() {
        twttr.ready(() => {
          twttr.widgets.createTimeline(widgetId, this.refs.container)
        })
      }
    
      render() {
        return 
    } }

    You can load the library directly from https://platform.twitter.com/widgets.js, but they recommend the following snippet:

    
    

    More information on setting up the library is here.

提交回复
热议问题