Dynamically update twitter "tweet button" widget in React

Has anyone ever used the tweet button widget within a React context?

I have a button on my polling app that basically tweets out:

“come vote on {topic} at {url} it looks like {option} is winning with {num} votes”

However I have a bug I cant fix. When a user votes I have my chart update right away infront of the user. There is not a page refresh (updated via a fetch() call) and because there isn’t a page refresh the twitter button doesn’t update that the {num} is {num += 1} despite my passing the correct value to the twitter button (confirmed with console log).

I’ve read about dynamically updating this button on stackoverflow here for example etc and it says you are supposed to be able to call twittr.widgets.load() to update all of the widgets on the page. but this STILL doesn’t work for me.

has anyone run into this problem before? Growing frustrated with this button!

I don’t know how you’re putting in the twitter widget, but if you have a react element that wraps the widget, then try putting twittr.widgets.load() into the componentDidMount method