JodusNodus / react-qr-reader

React component for reading QR codes from webcam.
https://jodusnodus.github.io/react-qr-reader
MIT License
1.13k stars 407 forks source link

Installation error | React version 18 #239

Open josefdclxvi opened 2 years ago

josefdclxvi commented 2 years ago

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: residencia@0.1.0 npm ERR! Found: react@18.0.0 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 react-qr-reader@3.0.0-beta-1 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 commented 2 years ago

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 commented 2 years ago

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)

iMiebaka commented 2 years ago

This solution still presents issues

nandyx commented 2 years ago

any update?

JanettaH commented 1 year ago

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

Jasperhino commented 1 year ago

Same issue here

leho-dev commented 1 year ago

me too

unllamas commented 1 year ago

Has anyone been able to solve it?

kazem3d commented 1 year ago

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

mateusz-pocztowski commented 1 year ago

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

pdtran3k6 commented 1 year ago

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!

otito12 commented 1 year ago

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!

whiskacz commented 11 months ago

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 👍

mh-jsx commented 1 month ago

if you have react > 17 Use this instead https://www.npmjs.com/package/react-zxing

Both the libraries are using @zxing/library under the hood.