saurabhnemade / react-twitter-embed

Simplest way to add twitter widgets to your react project.
https://saurabhnemade.github.io/react-twitter-embed/
367 stars 66 forks source link

Re-rendering component #44

Closed anurastogi closed 4 years ago

anurastogi commented 4 years ago

I am using the TwitterTweetEmbed component with a variable for the tweetId, in this manner:

<TwitterTweetEmbed tweetId={item.postID} placeholder="Loading" />

I have a <p>{item.postID}</p> along with this.

On a state change, the item.postID changes, which is reflected in the <p> tag, but the <TwitterTweetEmbed> still shows the tweet related to the previous postID. Anything needed to ensure that the component re-renders?

antoinefranz commented 4 years ago

You should add a key to your component: <TwitterTweetEmbed key={item.postID} tweetId={item.postID} placeholder="Loading" />

anurastogi commented 4 years ago

Thanks! That helped.

izmarsel commented 4 years ago

Me too. Thanks!!