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

support for [email protected]

Open AliSaberi opened this issue 2 years ago • 9 comments

It seems that the library does not support the react version 18.2.0

ERR! Found: [email protected] npm ERR! node_modules/react npm ERR! react@"18.2.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from [email protected] npm ERR! node_modules/react-lazyload npm ERR! react-lazyload@"*" from the root project

AliSaberi avatar Nov 27 '22 08:11 AliSaberi

Same with [email protected]

npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [REDACTED]@0.1.0
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from [email protected]
npm ERR! node_modules/react-lazyload
npm ERR!   react-lazyload@"3.2.0" from the root project

jeromelachaud avatar Nov 30 '22 15:11 jeromelachaud

I can see in the package.json file of this repository it supports React v18.x.x : https://github.com/twobin/react-lazyload/blob/f1faffda816180f39d3ff8cf3d9c2060f8d9d623/package.json#L61

But it seems that changes have not been published to the npm registry yet. Because until now the that I write this comment, the npm registry of this repo was updated 2 years ago the last time. https://www.npmjs.com/package/react-lazyload

peZhmanParsaee avatar Nov 30 '22 20:11 peZhmanParsaee

I know it does not actually solve the underlying issue but as a workaround adding custom type resolution to your package.json seems to get rid of the error.

for yarn

  "resolutions": {
    "@types/react": "^18.0.25"
  },

and for npm

"overrides": {
  "@types/react": "^18.0.25"
},

KonkretneKosteczki avatar Dec 01 '22 12:12 KonkretneKosteczki

I do already have "@types/react": "^18.0.25", entry as a devDependency.

jeromelachaud avatar Dec 01 '22 15:12 jeromelachaud

ho, did you mean?:

"overrides": {
    "react-lazyload": {
      "@types/react": "^18.0.25"
    }
  }

Still got the error any way

jeromelachaud avatar Dec 01 '22 15:12 jeromelachaud

@KonkretneKosteczki Thank you for this great tip.

@jeromelachaud The below change made the error to be gone:

"overrides": {
    "react-lazyload": {
      "react": "^18.2.0",
      "react-dom": "^18.2.0"
    }
  }

Actually react and react-dom should be set not @types/react

peZhmanParsaee avatar Dec 04 '22 14:12 peZhmanParsaee

Awesome 🔥 Thanks @peZhmanParsaee @KonkretneKosteczki!

jeromelachaud avatar Dec 04 '22 18:12 jeromelachaud

@ameerthehacker Would it be possible to make a release to npm with this? Its been a hassle.

ikarus-pritish avatar Feb 06 '23 06:02 ikarus-pritish

Thanks @peZhmanParsaee 💪

AakashRao-dev avatar Feb 15 '23 01:02 AakashRao-dev