Skip to content

Console Error: Accessing element.ref was removed in React 19. ref is now a regular prop. #8

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

Open
michaelcychan opened this issue Apr 1, 2025 · 2 comments

Comments

@michaelcychan
Copy link

Hello, we are reviewing your library and find it suitable for our needs.

Issue:
The PDF files can be loaded and displayed; however, I am encounter this error:

Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.

Image

Environment:

  • React: 19.0.0
  • Next.Js: 15.2.4
  • @pdf-viewer/react: 1.2.0

I encounter the same issue from your Next.js example and have the same Console Error.

Do you have any workaround or any plans to fix it? Thank you very much!

@david-reactpdf
Copy link
Contributor

@michaelcychan

Just echoing what I shared in my email (and posting here for anyone else following along): the warning you’re seeing about element.ref comes from a breaking change introduced in React 19:

Accessing element.ref was removed in React 19. ref is now a regular prop.

While not ideal, this doesn’t break functionality. We’ve tested React PDF with React 19, and everything still works as expected—so you can continue using the viewer without issue for now.

React PDF is still built with React 18 in mind, and full support for React 19 (including removing this warning) will likely require maintaining separate builds due to peer dependency differences. We’re actively monitoring adoption of React 19 and will align support in an upcoming release as it becomes more widespread in the ecosystem.

@xiaohanyu
Copy link

+1 for this warning.

Not sure whether there's way to suppress this warning.

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

No branches or pull requests

3 participants