vre2h/use-react-screenshot

Package not working with react 18

Opened this issue ยท 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

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.

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 As far as I remember, I didn't change anything else.

cynde commented

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

@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 use-react-screenshot@3.0.0
[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: react@17.0.2
[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 use-react-screenshot@3.0.0
[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

Delete the node module folder and try this :-

npm config set legacy-peer-deps true
npm install