react-qr-reader icon indicating copy to clipboard operation
react-qr-reader copied to clipboard

Installation error | React version 18

Open josefdclxvi opened this issue 2 years ago • 14 comments

Hi got this error when im trying to install react-qr-reader in version 18 of React

npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: [email protected] 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@"^16.8.0 || ^17.0.0" from [email protected] npm ERR! node_modules/react-qr-reader npm ERR! react-qr-reader@"*" 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. npm ERR!

josefdclxvi avatar Apr 16 '22 03:04 josefdclxvi

it works when i install it with --legacy-peer-deps npm add react-qr-reader --legacy-peer-deps

is it ok if i ignore the required version of react for this package? will there be conflicts in the future?

josefdclxvi avatar Apr 16 '22 03:04 josefdclxvi

i found the problem regarding in this lib with React 18

there is an error message from react that image

this react dom render inside index.js is now deprecated in React 18 image

instead, use createRoot image

when i tried to change this to createRoot, this lib starts to malfunction. it gets infinite loop after qr code capture the looping happen in onResult

so i switch back to render (ReactDOM.render)

josefdclxvi avatar Apr 17 '22 05:04 josefdclxvi

This solution still presents issues

iMiebaka avatar Jun 03 '22 16:06 iMiebaka

any update?

nandyx avatar Sep 05 '22 01:09 nandyx

This error still appears to be valid. Any updates on this? 👀

JanettaH avatar Oct 24 '22 05:10 JanettaH

Same issue here

Jasperhino avatar Nov 09 '22 20:11 Jasperhino

me too

leho-dev avatar Nov 16 '22 11:11 leho-dev

Has anyone been able to solve it?

unllamas avatar Nov 29 '22 01:11 unllamas

it is not solved yet you can use html5-qbarcode , with less dependancy this is an exapmle https://minhazav.medium.com/qr-and-barcode-scanner-in-react-b8e09102b805

kazem3d avatar Dec 05 '22 06:12 kazem3d

Try npm overrides in your package.json:

"overrides": {
  "react-qr-reader": {
    "react": "$react",
    "react-dom": "$react-dom"
  }
}

See https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

mateusz-pocztowski avatar Jan 04 '23 13:01 mateusz-pocztowski

Try npm overrides in your package.json:

"overrides": {
  "react-qr-reader": {
    "react": "$react",
    "react-dom": "$react-dom"
  }
}

See https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

This works for me, thanks!

pdtran3k6 avatar Jan 16 '23 13:01 pdtran3k6

Try npm overrides in your package.json:

"overrides": {
  "react-qr-reader": {
    "react": "$react",
    "react-dom": "$react-dom"
  }
}

See https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

Thank you!

otito12 avatar Jun 14 '23 15:06 otito12

Try npm overrides in your package.json:

"overrides": {
  "react-qr-reader": {
    "react": "$react",
    "react-dom": "$react-dom"
  }
}

See https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

it works, thanks 👍

whiskacz avatar Sep 30 '23 08:09 whiskacz