Going to the twitter widget site (https://publish.twitter.com/) I am able to get a widget to add to my site. I am using the sample code to try to understand hot it works:
<a class="twitter-grid" href="https://twitter.com/TwitterDev/timelines/539487832448843776">National Park Tweets</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
If I just add this to an HTML page then the code works exactly as it should. It shows the grid with the respective tweets.
However, when adding this to ReactJS all I see is the fallback code, which merely provides a link to the twitter username.
I have tried using the following to no avail:
<div dangerouslySetInnerHTML={{__html: "<a className='twitter-grid' href='https://twitter.com/TwitterDev/timelines/539487832448843776'>National Park Tweets</a> <script async src='https://platform.twitter.com/widgets.js' charset='utf-8'></script>"}}>
</div>
The good news is that you can just embed a Twitter widget on your website for that. This way, you can increase user engagement to your Twitter account and establish brand awareness. Plus, when you display a Twitter timeline widget, your customers can see it while checking out your product catalog or blog posts.
Find the tweet you'd like to embed. Click the downward arrow on the top-right of your tweet. Choose "Embed Tweet." Copy the code that appears and paste it into your website's HTML editor.
Check out this npm package: react-twitter-widgets. This seems to be accomplishing what you need out of box.
import { Tweet } from 'react-twitter-widgets'
ReactDOM.render(<Tweet tweetId='511181794914627584'/>, document.getElementById('root'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With