React-share: How to pass image as thumbnail?

323 views Asked by At

In my project, the react-share package is used for the share button functionality. I would like to send an image as a thumbnail along with the URL, but how can I make it happen?

<FacebookShareButton
    url={openShare.link}
    onClick={() => handleClose() }
>

    <FacebookIcon size={40} round={true} />
</FacebookShareButton>

<WhatsappShareButton
    url={openShare.link}
    onClick={() => handleClose()}
>
1

There are 1 answers

4
Allan On

import { FacebookShareButton, WhatsappShareButton } from 'react-share';

const shareUrl = openShare.link; // Replace with your actual URL
const imageUrl = 'https://example.com/path/to/image.jpg'; // Replace with the URL of your image

<FacebookShareButton
  url={shareUrl}
  onClick={() => handleClose()}
  quote="Check out this awesome website!"
  hashtag="#react"
  image={imageUrl} // Add the image URL here
>
  <FacebookIcon size={40} round={true} />
</FacebookShareButton>

<WhatsappShareButton
  url={shareUrl}
  onClick={() => handleClose()}
>
 {/* Add your custom WhatsApp button */}
</WhatsappShareButton>