Search code examples
javascriptreactjslinkedin-apireact-share

react-share can't share LinkedIn article


I tried to share article current URL to social media such as Facebook, Twitter & LinkedIn using react-share package. I have some issues at share the page: null (URL: https://www.linkedin.com/shareArticle/?url=https%3A%2F%2Fstaging.bidboxid.co%2Fcar-details%2Fhonda-brio-at-limited-edition&mini=true)

code:

import React from 'react';
import { LinkedinShareButton } from "react-share";
let shareUrl = window.location.href;

export default class Share extends React.Component {
   render() {
      return(
      <LinkedinShareButton url={`${shareUrl}`}>
         <div className="icon-socmed-white linkedin">
            <FaLinkedinIn/>
         </div>
      </LinkedinShareButton>)
   }
}

What weird of this case, if I tried to share the homepage page as share article it'll works just fine.


Solution

  • Seems like linkedin has removed their support for sharing URLs. If you check the documentation (https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin?context=linkedin/consumer/context) it never mentions sharing using a URL.

    Sharing the homepage probably still works because they missed removing support for that type of URL yet.

    Most likely react-share has to be updated/will no longer support LinkedIn. You can follow the documentation above to know how to implement the sharing yourself.

    LE: here is another stackoverflow answer saying the same thing: How to make a custom LinkedIn share button