Get embed tweet widget with react.js

Viewed 288

I am going to show embed tweet data on the react project. In publish.twitter.com, they show that publish code about embed tweet.

<a class="twitter-timeline" href="https://twitter.com/twitterDev?ref_src=twsrc%5Etfw" data-tweet-limit="3">Tweets by twitterDev</a> 
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

But in react project, it doesn't work, only shows <a>tag -Tweets by twitterDev. Please help me.

1 Answers

Please try with following.

React.useEffect(() => {
    const script = document.createElement("script");
    script.setAttribute("src", "https://platform.twitter.com/widgets.js");
    document.getElementsByClassName("lists")[0].appendChild(script);
}, []);
<a class="twitter-timeline" href="https://twitter.com/twitterDev?ref_src=twsrc%5Etfw" data-tweet-limit="3">Tweets by twitterDev</a> 

Hope to your business will be good.

Related