nygardk / react-share

Social media share buttons and share counts for React
MIT License
2.63k stars 433 forks source link

Update package that it could be used in project which includes react 18 #442

Open michalstrzelecki opened 2 years ago

michalstrzelecki commented 2 years ago

npm update gives:

npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.3.0 || ^17" from react-share@4.4.0
npm ERR! node_modules/react-share
npm ERR!   react-share@"^4.4.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Please, add react to peerDependecies as:

"react": ">=16.3.0"

I can not use this package in a project that includes react 18.

samgermain commented 2 years ago

I second this

AndreasFaust commented 2 years ago

Is this fixed? For me it works along React 18.

NElnour commented 2 years ago

Is this fixed? For me it works along React 18.

@AndreasFaust how did you make it work?

rossm6 commented 2 years ago

Add to package.json

"overrides": {
    "react-share": {
      "react": "18.0.0",
      "react-dom": "18.0.0"
    }
  }
zumek commented 2 years ago

I'm using react 18.1.0 and still don't work after overriding as suggested above. Tried the following as well, no luck :(

"overrides": {
    "react": "18.1.0",
    "react-dom": "18.1.0"
  },  
NElnour commented 2 years ago

@rossm6 it worked thanks! @zumek you need to specify that the overrides are for react-share, so it should be

...,
  "overrides": {
    "react-share": { <---- this is what you're missing!
      "react": "18.1.0",
      "react-dom": "18.1.0"
    }
  },
zumek commented 2 years ago

@rossm6 thanks but, I tried that and it didn't work. So I tried the global override option, which doesn't work either for some reason.

DevAkintunde commented 2 years ago

Thanks, works for me