Closed anurastogi closed 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.
<p>{item.postID}</p>
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?
<p>
<TwitterTweetEmbed>
You should add a key to your component: <TwitterTweetEmbed key={item.postID} tweetId={item.postID} placeholder="Loading" />
<TwitterTweetEmbed key={item.postID} tweetId={item.postID} placeholder="Loading" />
Thanks! That helped.
Me too. Thanks!!
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?