react-share icon indicating copy to clipboard operation
react-share copied to clipboard

[Error] EmailShareButton is not working

Open JaeWangL opened this issue 4 years ago • 16 comments

            <EmailShareButton style={{ margin: '0.5rem' }} url={publicUrl} subject='t' body="<div>test</div>">
                <EmailIcon size={60} round />
            </EmailShareButton>,

Here is my code when I click button, nothing happen

my package is

"react": "^16.12.0",
"react-share": "^4.0.1",

JaeWangL avatar Mar 11 '20 07:03 JaeWangL

That is weird. Were you able to fix the issue?

nygardk avatar Mar 14 '20 08:03 nygardk

The same issue with Twitter share button

Wellusioner avatar Mar 20 '20 12:03 Wellusioner

same issue with almost every component

iamsarthakjoshi avatar Apr 03 '20 11:04 iamsarthakjoshi

@nygardk @JaeWangL did you guys find the isuue i am facing same issue

hammadtariq98 avatar Apr 17 '20 10:04 hammadtariq98

problem with email share button

ghost avatar Apr 28 '20 05:04 ghost

Also dealing with this issue - the button does not respond to any clicks. I'm also using the share buttons for Pinterest, Facebook, Twitter that successfully perform their actions.

rlau1115 avatar Apr 29 '20 23:04 rlau1115

I guess you haven't set default app for reading mail. If you are using window 10, you can try: https://www.officetooltips.com/office_2016/tips/how_to_modify_default_mail_client_in_windows_10.html

Do the similar thing with other OS

PhuongLe21 avatar May 05 '20 08:05 PhuongLe21

how to share through gmail without using defaul mail reading app

joypraba avatar May 16 '20 11:05 joypraba

Same here. Using the HTML anchor tag with mailto inside the href works fine. In the console, i get Uncaught TypeError: b is not a function

tareqdayya avatar Jul 17 '20 10:07 tareqdayya

same here with email, I am on windows 10 and my default email app is google chrome. I also agree there should be a way to set a fallback.

laclance avatar Jul 26 '20 06:07 laclance

I haven't investigated, but it seems a trick to see if the user has a working email client is to check the onBlur event (if it fires, it means it worked)

https://www.uncinc.nl/nl/articles/dealing-mailto-links-if-no-mail-client-available (old post with jQuery, but the code would obviously be working fine in native js)

$(window).blur(function() {
        // The browser apparently responded, so stop the timeout.
        clearTimeout(t);
      });

      t = setTimeout(function() {
        // The browser did not respond after 500ms, so open an alternative URL.
        document.location.href = '...';
      }, 500);

tttp avatar Jul 26 '20 08:07 tttp

I just pulled the repo and ran the demos locally. The email button, with the email icon nested as a child, works just fine. Could be something in the Webpack config?

tareqdayya avatar Jul 26 '20 09:07 tareqdayya

Exact same behaviour for me as for @tareqdayya - the demo work locally just fine, but none of the share buttons do anything when imported into my React 16.13.1 project.

blasphemic avatar Aug 28 '20 16:08 blasphemic

@blasphemic I've used this workaround until it gets fixed:

const handleEmailOnClick = () => {
    window.location.href = encodeURI(`mailto:
    ?subject=${Some.Variable} Subject Here
    &body=Hi,\n\nYou Can bla Bla bla "${some.variable}" At ${url}\n\nEnjoy,`);
  };
return (
  <EmailShareButton url={MY_URL} onClick={handleEmailOnClick}>
        <EmailIcon />
   </EmailShareButton>
);

tareqdayya avatar Aug 28 '20 20:08 tareqdayya

Hello, one more guy bumping into the issue here 👋 @tareqdayya thanks, I tried the approach you suggested and it worked on most of the browsers I needed, unfortunately, except Safari on iOS. Ended up rendering just an anchor tag with mailto:... and styling it to match the rest of my share buttons.

kirill-kruchkov avatar Sep 20 '20 09:09 kirill-kruchkov

Hello, one more guy bumping into the issue here @tareqdayya thanks, I tried the approach you suggested and it worked on most of the browsers I needed, unfortunately, except Safari on iOS. Ended up rendering just an anchor tag with mailto:... and styling it to match the rest of my share buttons.

how to use that anchor tag into our could u pls share the code

Tejas21-design avatar Jan 21 '21 15:01 Tejas21-design