react-twitter-embed icon indicating copy to clipboard operation
react-twitter-embed copied to clipboard

TwitterShareButton url prop not working properly

Open lucianourgal opened this issue 3 years ago • 3 comments

Hi all,

I've run into two issues with the TwitterShareButton:

Condition:

  • Set a different URL to the TwitterShareButton Expected behavior:
  • This different URL should appear at the twitter post Found behavior:
  • The post shows the current url the button is at

Condition:

  • URL of TwitterShareButton is set as empty or null Expected behavior:
  • No URL should appear at the twitter post Found behavior:
  • The post shows the current url the button is at

Code as follows:

` import React from "react"; import {TwitterShareButton} from "react-twitter-embed"; import s from "./twitterTweet.scss";

const TwiterTweet: React.FC<ITwit> = ({ text, url, author, buttonSize = "large" }) => { return ( <div className={s.tweetButton}> <TwitterShareButton url={url} options={{ text: text, via: author, size: buttonSize }} placeholder="Loading" /> ); };

export default TwiterTweet; `

lucianourgal avatar Jan 31 '22 18:01 lucianourgal

@lucianourgal on version 4.0.4?

saurabhnemade avatar Jan 31 '22 19:01 saurabhnemade

To avoid re-rendering it was never added even in the previous version (https://github.com/saurabhnemade/react-twitter-embed/blob/example-updated/src/components/TwitterShareButton.js). However if you are still trying to achieve this, you can try like following by adding key:

https://codesandbox.io/s/jolly-wood-is0zk?file=/src/TwiterTweet.js

saurabhnemade avatar Jan 31 '22 19:01 saurabhnemade

Thanks for replying @saurabhnemade . I'm actually using v4.0.6.

lucianourgal avatar Jan 31 '22 20:01 lucianourgal