use-react-screenshot icon indicating copy to clipboard operation
use-react-screenshot copied to clipboard

Package not working with react 18

Open rohailtaha opened this issue 2 years ago • 6 comments

I cannot use use-react-screenshot with react 18. It has a peer dependency of react 17. Could you please update it, otherwise I'll have to downgrade react just for this package. This is the error log I get when I run npm i use-react-screenshot: image

rohailtaha avatar Oct 02 '22 15:10 rohailtaha

I successfully installed the package with the flag --legacy-peer-deps like so: npm i use-react-screenshot --legacy-peer-deps and it works. But issue with peer dependency still need to be resolved.

rohailtaha avatar Oct 02 '22 16:10 rohailtaha

hi @rohailtaha, this is still not working in my react 18.2.0 project. I have tried using --force and --legacy--peer-deps. Did you have to make any other changes to your code?

ImranQUB avatar Dec 24 '22 12:12 ImranQUB

@ImranQUB As far as I remember, I didn't change anything else.

rohailtaha avatar Dec 24 '22 15:12 rohailtaha

@ImranQUB Maybe you need to install the peerDependencies first: npm install --save react html2canvas

cynde avatar Jan 10 '23 06:01 cynde

@cynde To be clear, the API functions are working as expected with react 18.2.0, react html2canvas 1.4.1, and use-react-screenshot 3.0.0 during development. I have uninstalled and reinstalled the peerDependencies multiple times and get the same npm error during production builds, see below.

npm ERR! Could not resolve dependency: [2023-01-12 05:35:28] │ npm ERR! peer react@"^17.0.2" from [email protected] [2023-01-12 05:35:28] │ npm ERR! node_modules/use-react-screenshot [2023-01-12 05:35:28] │ npm ERR! use-react-screenshot@"^3.0.0" from the root project [2023-01-12 05:35:28] │ npm ERR! [2023-01-12 05:35:28] │ npm ERR! Conflicting peer dependency: [email protected] [2023-01-12 05:35:28] │ npm ERR! node_modules/react [2023-01-12 05:35:28] │ npm ERR! peer react@"^17.0.2" from [email protected] [2023-01-12 05:35:28] │ npm ERR! node_modules/use-react-screenshot [2023-01-12 05:35:28] │ npm ERR! use-react-screenshot@"^3.0.0" from the root project [2023-01-12 05:35:28] │ npm ERR! [2023-01-12 05:35:28] │ npm ERR! Fix the upstream dependency conflict, or retry [2023-01-12 05:35:28] │ npm ERR! this command with --force, or --legacy-peer-deps [2023-01-12 05:35:28] │ npm ERR! to accept an incorrect (and potentially broken) dependency resolution. [2023-01-12 05:35:28] │ npm ERR!

Any suggestions? If needed, I can provide more details about the project.

Thanks

ImranQUB avatar Jan 12 '23 18:01 ImranQUB

Delete the node module folder and try this :-

npm config set legacy-peer-deps true npm install

Aashishweb avatar Feb 03 '23 06:02 Aashishweb