react-share Compatibility issue with 15.x Version of react

163 Views Asked by At

I am using react-share with react 15.6 version. and getting the following error

TypeError: react__WEBPACK_IMPORTED_MODULE_9___default.a.forwardRef is not a function

Here is my Code Snippet

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

<WhatsappShareButton
  url={url}
  title={title}
  children={<WhatsappIcon
             size={32}
             round />} />

Any one who is using react share getting same error or anyone find the solution?

1

There are 1 best solutions below

3
On

According to the README it should be compatible:

Compatibility

Version 1.x.x: compatible with React versions 0.13.x, 0.14.x and 15.x.x.

Version 2.x.x: compatiblity is tested with React 15 and 16.

Version 3.x.x: compatiblity is tested with React 15 and 16.

However, it is not uncommon in the npm universe that such incompatibilities occur, especially if you are not upgrading all your dependencies consistently.

In those cases you should however search for the existing GitHub issue or create one, instead of an SO question, because once they are resolved, they serve little purpose here:

Starting from version 3.0.1 this awesome library become incopatible with React v15.X because of using forwardRef in this commit: 3dc5b94

The solution you are looking for is to downgrade to react-share 3.0.0 until the issue is being resolved or upgrade to react 16.