diegomura / diegomura/react-pdf
<Image /> throws error when using in NextJS with swcMinify
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
I'm using react-pdf with nextjs (v12). When running in dev mode everything works as expected.
When building the app for production with `swcMinfiy: true` in `next.config.js` I'm getting the following error on the component
```
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'width')
at drawImage (_app-4582e1627b46c737.js:115:440420)
at renderImage (_app-4582e1627b46c737.js:115:440829)
at renderNode (_app-4582e1627b46c737.js:115:452973)
at d (_app-4582e1627b46c737.js:115:452461)
at Array.forEach ()
at renderChildren (_app-4582e1627b46c737.js:115:452482)
at renderNode (_app-4582e1627b46c737.js:115:452985)
at d (_app-4582e1627b46c737.js:115:452461)
at Array.forEach ()
at renderChildren (_app-4582e1627b46c737.js:115:452482)
```
Using `swcMinify: false` it works as expected.
But swc is considered best practice/ stable and is on per default starting Nextjs v13. So leaving it off can't be the solution.
**To Reproduce**
as described above
**Expected behavior**
Should not throw error
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: MacOS M1
- Browser: Chrome
- Nextjs v12
- React v18
- React-pdf v.3.0.0
Contributor guide
Assessment
This issue has not been assessed yet.