-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 React 17 #1062
Comments
Any update on this? |
Interested too |
it might help you |
This is a quick fix that solves the situation temporary, but if you remove the lock file, you have to use it again. It is not a clean solution... |
Made a pull request to bump react version here: #1157 |
Hi! Sorry for the delay! |
@diegomura Maybe you can add both, with version range, until you test it. |
So I tried upgrading react's peer dependency from The newest It seems that the cause of this is NPMv7 now installs peer dependencies and breaks things (this is apparently breaking the react library ecosystem, not just this package). I'm open to suggestions here but I do not see how I can keep supporting all react versions and making NPMv7 to work, unless you use the For those blocked by this, it is not that you cannot use the lib with React17 and NPM7, it jus throws this error when installing |
Just published |
@diegomura I tried on 2.0.0 and 1.6.16, but unfotunately it doesn't work without --legacy-peer-dep flag |
Yes. As explained above, I couldn't find the way of keep supporting react 16 and 17. This whole peer dependency check in nvm@7 breaks this library. The issue is not just react-pdf peer dependency but specially |
Hi @diegomura I see the problem. Maybe solution with aliases could help in this case? https://dev.to/joshx/test-your-npm-package-against-multiple-versions-of-its-peer-dependency-34j4 |
Interesting.. But I don't think npm aliases can solve this. I will still have to list a React official renderers builds, such as react-dom or react-native, are shipped with the |
Hi @diegomura
I think it's a good point.
Maybe I'm completely wrong, but I have an assumption why npm always installs latest minor version, probably because |
Thanks @maxdev ! That might be right. Will try today and report back here |
I can confirm that it is still broken |
Thanks @KarlBaumann. It is :( but as explained above I'm on a dead end for both supporting react 16 and 17 with the new npm peer dependency install |
@diegomura |
While I generally agree, with React for me it's more complex. Since it's the main peer dependency of this project and one of those libraries that people usually do not update right away, just stopping support for React 16 would leave many people behind. It's not that people using React17 cannot use latest build either. For what I understood, the only issue is with the latest npm peer dependency check, right? |
for me it does not work also with the peer-dependency-check disabled. It is totally normal that major releases introduce breaking changes. Thats why I would expect that everyone who is already using the library, has something like this ^2.0.0 in their package.lock file, so your version 3 would not break their apps. |
Just curious, how long do you forsee supporting React 16? |
I don't have any fixed plan. I'm open to suggestions 😄 Would still love to see if there's some solution to this. @KarlBaumann releasing a 3.x it's not an option since that would be even more confusing |
How difficult would it be to create a React 17 compatible version as a temp measure for those of us on React 17? i.e. leave 16 as the main supported version it's time for the whole thing to officially move to be based on React 17? |
1+. This library seems super useful and our team would like to use it in our production application to generate a PDF and download it. We use React 17 however and there aren't many other alternatives that provide a solution to this :( I think making a separate version for React 17 and one for React 16 would be a good way to temporarily solve this issue as mentioned by @grmatthews. |
Waiting for React 17 support |
Waiting for React 17 Support, Planning to use this lib in our production env |
Any update here? @diegomura |
Waiting for React 17 Support |
Would also like React 17 support |
I was curious how other packages are handling this. react-router is using 17 and react-redux uses both. For what it's worth, Wes Bos recommends the same thing as @mquandalle. As of the end of October Node 16 (NPM 7) is the active LTS; I think this is going to be increasingly problematic as people start switching over and I think it should be a quick fix. Would be glad to submit a PR with maybe some hints on how I can test. |
PR above implements what mquandelle suggested on May 10, 2021. Seems to fix the problem in our end at least. |
Still doesn't worked for me |
@diegomura with the React version 18 release just around the corner, what do you think about upgrading to React 17 (dropping support for React 16) and publishing a new major version of |
One additional detail here is that upgrading to React 17 enables usage of the new JSX transform, which would allow for leaving out the |
Just ran into a problem trying to use The incompatibility with React 17 is causing an error like this:
This was caused by the {
"compilerOptions": {
"jsx": "react-jsx"
}
} Workaround 1To work around
{
"compilerOptions": {
- "jsx": "react-jsx"
+ "jsx": "preserve"
}
} Workaround 2The workaround described under Workaround 1 above caused weird build errors: $ yarn build
✨ Done in 7.81s.
$ yarn start
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/runner/work/build/learningOutcomesPdf.js' imported from /home/runner/work/build/index.js
at new NodeError (node:internal/errors:371:5)
at finalizeResolution (node:internal/modules/esm/resolve:418:11)
at moduleResolve (node:internal/modules/esm/resolve:981:10)
at defaultResolve (node:internal/modules/esm/resolve:1078:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)
at link (node:internal/modules/esm/module_job:78:36) {
code: 'ERR_MODULE_NOT_FOUND'
} We took a look inside the $ ls build/
learningOutcomesPdf.jsx This is because TypeScript builds So we couldn't use the Instead, we removed that /** @jsxImportSource react */ This almost worked! 🙌 And probably would work for many teams. But because our package is a Node.js ESM package, we had further problems with Node.js not resolving
For this, we needed to patch React 17 with the diff --git a/node_modules/react/package.json b/node_modules/react/package.json
index 936478a..65e2461 100644
--- a/node_modules/react/package.json
+++ b/node_modules/react/package.json
@@ -19,6 +19,11 @@
"jsx-dev-runtime.js"
],
"main": "index.js",
+ "exports": {
+ ".": "./index.js",
+ "./jsx-dev-runtime": "./jsx-dev-runtime.js",
+ "./jsx-runtime": "./jsx-runtime.js"
+ },
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git", |
cc @jeetiss, since it seems that you are also an active maintainer here |
Gonna +1 the official support of React 18. So far we had no problem running this with React 17, by simply using the legacy peer deps, haven't tried v18 though. |
|
Hm, but it fails with
|
Found some time to take a look at this, and opened a PR to fix the types in the However, this does not fix the other packages in the monorepo. And this may cause breakage for |
In the meantime, while i get more insight about this.. Watchers please drop any light if any! (This is using --legacy-peer-deps alternative with react-scripts 5.0.1 / react 18) Creating an optimized production build... Module not found: Error: Can't resolve 'stream' in '...../node_modules/@react-pdf/pdfkit/lib' If you want to include a polyfill, you need to: |
I think that possible solution is use Nowadays, latest major |
Any news? Will the fate of the enzyme overtake this library? Its been 2 years but you still dont support React 17... |
Still seeking React 17 support at least (if not React 18). That'd be much appreciated :) I'm considering forking it for now and implementing the above changes since I'm pretty reliant on this library, but that's obviously not an ideal solution. I can try pushing a PR back into the project if I get it working...but I'd have to get a go-ahead for something that might harm React 16 support (which IMHO should just be dropped at this point, since it's now 2 major versions behind and has dropping market share). |
should be fixed in #2140 |
* Fix types for React v18 Ref: #1062 (comment) Ref: https://github.com/eps1lon/types-react-codemod#implicit-children Ref: DefinitelyTyped/DefinitelyTyped#46691 * add changeset --------- Co-authored-by: Dmitry Ivakhnenko <jeetiss@yandex.ru>
NPM v7 throws the following error when using react-pdf with the latest version of React
I'm not sure if there are any code migration required or if only the
package.json
needs to me modified.The text was updated successfully, but these errors were encountered: