Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for React 19 #2912

Closed
wkigenyi opened this issue Oct 23, 2024 · 23 comments
Closed

Support for React 19 #2912

wkigenyi opened this issue Oct 23, 2024 · 23 comments

Comments

@wkigenyi
Copy link

Hi,

Thanks for the wonderful library. It works well with <= React v18. Is there a plan to support React 19?

@ck-euan
Copy link

ck-euan commented Oct 23, 2024

This PR updates the package for react 19 (#2783). You could temporarily use the forked package to get it working now @alexandernanberg/react-pdf-renderer

@wkigenyi
Copy link
Author

Thanks I will try it.

@wkigenyi
Copy link
Author

This PR updates the package for react 19 (#2783). You could temporarily use the forked package to get it working now @alexandernanberg/react-pdf-renderer

I have forked your repo. But for some reason the cloning process timeouts before completing.
If I succeed with the cloning, could guide me on how I can import the package into my react project?

@ck-euan
Copy link

ck-euan commented Oct 24, 2024

This PR updates the package for react 19 (#2783). You could temporarily use the forked package to get it working now @alexandernanberg/react-pdf-renderer

I have forked your repo. But for some reason the cloning process timeouts before completing. If I succeed with the cloning, could guide me on how I can import the package into my react project?

@wkigenyi The easiest way would be to just install @alexandernanberg/react-pdf-renderer and simply replace any of the imports to use that instead

@wkigenyi
Copy link
Author

Thank you.

@jpainam
Copy link

jpainam commented Oct 31, 2024

Does @alexandernanberg/react-pdf-renderer support Nextjs 15?

@wkigenyi
Copy link
Author

Yes it does

@pedro757
Copy link

Have any of you guys run into this issue? @ck-euan @wkigenyi

details:
@alexandernanberg/[email protected]
[email protected]

Error:
⨯ TypeError: Cannot read properties of undefined (reading 'S')

@ck-euan
Copy link

ck-euan commented Oct 31, 2024

@pedro757 Yeah I just ran into that issue.
I believe that the PR needs to be updated with newer versions of react, react-dom and react-reconciler.

I was able to solve it by patching @react-pdf/renderer.

Basically I just copied all of the changes made in #2783 but I updated the versions to the following:
react: 19.0.0-rc-02c0e824-20241028
react-dom: 19.0.0-rc-02c0e824-20241028
react-reconciler: 0.31.0-rc-02c0e824-20241028

Specifically, the exact steps I took to do this were:

  1. Cloned React 19 #2783 locally
  2. Updated react, react-dom and react-reconciler to their latest rc versions
  3. Ran yarn build to build the @react-pdf/renderer packages locally, this gives you the lib folder. We will need to copy this for our patch.
  4. I'm using pnpm so I was able to run pnpm patch @react-pdf/[email protected] however you can do the same with patch package if you don't use pnpm
  5. The changes I made for the patch were to replace the existing lib folder from @react-pdf/renderer with the new one I built locally.
  6. Saved the patch with pnpm patch-commit ...

It then started to work for me. I really hope react 19 stable release happens soon 😅

@jpainam
Copy link

jpainam commented Oct 31, 2024

Yes it does

No, it's doesn't work with nextjs 15 and react 19. I get this error now

@wkigenyi

 TypeError: Cannot read properties of undefined (reading 'S')
    at module.exports (.next/server/chunks/08b5e_@alexandernanberg_react-pdf-renderer_lib_react-pdf_1362ba.js:14494:67)
    at createRenderer (.next/server/chunks/08b5e_@alexandernanberg_react-pdf-renderer_lib_react-pdf_1362ba.js:14980:12)
    at pdf (/.next/server/chunks/08b5e_@alexandernanberg_react-pdf-renderer_lib_react-pdf_1362ba.js:15180:28)
    at renderToStream (/.next/server/chunks/08b5e_@alexandernanberg_react-pdf-renderer_lib_react-pdf_1362ba.js:15311:22)

@wkigenyi
Copy link
Author

It worked for me and still works. How did you install yours?

@sam3d
Copy link

sam3d commented Oct 31, 2024

@wkigenyi is there any chance you could share your package.json and lockfile?

@wkigenyi
Copy link
Author

This good pointer. I have remembered that I actually have 2 packages "@alexandernanberg/react-pdf-renderer": "4.0.0-canary-3" and "@react-pdf/renderer": "^4.0.0". I imported the PDFDownloadLink from "@alexander..." the components and other functions from "@react-pdf/renderer"

@jpainam
Copy link

jpainam commented Oct 31, 2024

@alexandernanberg/react-pdf-renderer

Installed using pnpm add @alexandernanberg/react-pdf-renderer. Got this in my package.json "@alexandernanberg/react-pdf-renderer": "4.0.0-canary-3",
i'm server rendering, so i'm using renderToStream

@pedro757
Copy link

Specifically, the exact steps I took to do this were:

Thank you @ck-euan !, That works, good workaround.

@wkigenyi
Copy link
Author

wkigenyi commented Nov 1, 2024

This good pointer. I have remembered that I actually have 2 packages "@alexandernanberg/react-pdf-renderer": "4.0.0-canary-3" and "@react-pdf/renderer": "^4.0.0". I imported the PDFDownloadLink from "@alexander..." the components and other functions from "@react-pdf/renderer"

@sam3d did this work for you ?

@wkigenyi
Copy link
Author

wkigenyi commented Nov 5, 2024

@ck-euan I sometimes run into this error on re-rendering
TypeError: detachDeletedInstance is not a function

@Rohit-Ahirwal
Copy link

Hey guys @ck-euan @wkigenyi

please guide me to solve this error
⨯ TypeError: Cannot read properties of undefined (reading 'S')

@wkigenyi
Copy link
Author

wkigenyi commented Nov 7, 2024

Hi, I have decided to wait for stable react 19 release because what I thought was working is actually not working as expected

@pedro757
Copy link

pedro757 commented Nov 7, 2024

Hey guys @ck-euan @wkigenyi

please guide me to solve this error ⨯ TypeError: Cannot read properties of undefined (reading 'S')

ck-euan already helped us to workaround this, just read and follow this #2912 (comment)

@jpainam
Copy link

jpainam commented Nov 7, 2024

@pedro757 the workaround doesn’t work for next 15 and react 19. Server rendering. I used renderToStream

@ck-euan
Copy link

ck-euan commented Nov 7, 2024

@jpainam I am using the workaround in my Next 15 React 19 project with renderToStream so it should work. The chances are you just need different versions of react / react-dom / react-reconciler.

That being said, if possible it'd probably be better to wait for the stable release

@diegomura
Copy link
Owner

Let's keep the conversation in a single thread. Closing in favor of #2756

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants
@jpainam @diegomura @sam3d @wkigenyi @pedro757 @Rohit-Ahirwal @ck-euan and others