You can use react-18-pdf/renderer instead of react-pdf/renderer
npm i @react-18-pdf/renderer
只需使用--force
运行它,如下所示:
npm i @react-pdf/renderer --force
As suggested in error, it require react@"^16.8.6 || ^17.0.0" as peer dependency. So it will not work with react 18.
npm i @craco/craco
Check here
use this package, it works. When I was working in a project of making PDF using @react-pdf/renderer, I got the same Breaking changes error. I got resolved with CRACO package.
c reate R eact A pp C onfiguration O verride is an easy and comprehensible configuration layer for create-react-app.
Get all the benefits of create-react-app and customization without using 'eject' by adding a single configuration (eg craco.config.js) file at the root of your application and customize your eslint, babel, postcss configurations and many more.
While it is possible to install @react-pdf/renderer
discarding error the using any of following two methods
1.
npm install @react-pdf/renderer --legacy-peer-deps
"overrides": {
"@react-pdf/renderer": {
"react": "^18.0.0"
}
},
But I would recommend against it since, I was doing the same and faced with error in next export
due to @react-pdf/renderer
. Instead I replaced jsPDF while it is not declarative, it just get the job done for generating PDFs.
Add this to your package.json file and it solves the error
"overrides": {
"@react-pdf/renderer": {
"react": "^18.0.0"
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.