-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Multiple versions of @types/react
causes TypeScript errors when using react-native-svg
on a bare workflow
#17782
Comments
Adding in the old version as under EDIT: This also does not fix the issue in my actual project, which is vastly more complicated. |
Hello @ngregory-rbi, unfortunately supporting React 18 it's a bit more complicated than upgrading the package version in dependencies, and even latest version of stable React Native release do not truly support React 18. Not sure how your project is setup and why the newer version of types is fetch in there, but for now you should use React 17 in RN and Expo projects and forcing Refs: https://twitter.com/Kelset/status/1534881745774039045/photo/1 You can read a little bit more about the relation between React Native and React 18 in the official docs: Also, you probably should not use |
I explained clearly in my original post about why the newer version of the types are being pulled in. It's because
Unfortunately, my actual project is much more complicated, and setting the resolution broke other dependencies. Additionally, for some reason, my current project type-checks any elements I use by the types in If there was some way to tell the TypeScript compiler which version of
|
You can use the
This is probably due to usage of dependencies with mixed compatibility, which part of uses React 17 and some React 18. If you are not able to move the whole app to React 18, you should stay on the older version of packages, until you are able to do the full upgrade. Downgrade of the problematic packages should also resolve this problem. |
Unfortunately, due to business requirements, this is not possible. As mentioned though, it appears part of my issue is with the TypeScript complier checking my use of components against the wrong version of I just more wanted to inform y'all about how your current workflow for bare apps does not support |
I wasn't able to reproduce the problem with clean bare app generated from template and
That's nice to hear! So, can we close this issue, or is there something else you would like to add? |
Fascinating. I'm not sure what you did differently because I thought I did the same, given that all I did was run
If you were unable to reproduce, then perhaps. I would still be curious as to what we did differently, though. |
There is also a know problem when working with certain versions of the types packages, and it has nothing to do with the Expo, React Native or any other third-party libraries. The problem has been reported a while ago in DT repository, and it has lead to the many false report in various places, see:
I have checked out your app too, build it and run it on real hardware without any changes and I still cannot reproduce the problem, no warnings or errors are present. So maybe there is something wrong with you Editor/IDE setup, from the previous cases I know that VSCode have some issue with React types too. Saying that, I'm going to close the issue due to lack of correct repro since the discussion in there become a little bit unproductive. If you will be able to provide the repro which will always result in errors or warnings, no matter of the machine feel free to create a new issue. |
Hi there! It looks like your issue requires a minimal reproducible example, but it is invalid or absent. Please prepare such an example and share it in a new issue. The best way to get attention to your issue is to provide a clean and easy way for a developer to reproduce the issue on their own machine. Please do not provide your entire project, or a project with more code than is necessary to reproduce the issue. A side benefit of going through the process of narrowing down the minimal amount of code needed to reproduce the issue is that you may get lucky and discover that the bug is due to a mistake in your application code that you can quickly fix on your own. ResourcesCommon concerns"I've only been able to reproduce it in private, proprietary code"You may not have spent enough time narrowing down the root cause of the issue. Try out the techniques discussed in this manual debugging guide to learn how to isolate the problem from the rest of your codebase. "I didn't have time to create one"That's understandable, it can take some time to prepare. We ask that you hold off on filing an issue until you are able to fully complete the required fields in the issue template. "You can reproduce it by yourself by creating a project and following these steps"This is useful knowledge, but it's still valuable to have the resulting project that is produced from running the steps, where you have verified you can reproduce the issue. |
Summary
After running
expo init
(using the blank TypeScript template and thenexpo eject
on a brand new environment, of the many packages installed, there are:@types/react@17.0.45
1@types/react-native@0.66.18
2@types/react@18.0.12
3Then running
expo install react-native-svg
,react-native-svg@12.3.0
is installed.Attempting to use any component from that package though leads to a TS2786 error (
... is not a valid JSX element
). When I researched this in reference toreact-native-svg
the issue of multiple versions of@types/react
came up as the cause, and that does appear to be what is happening here.Managed or bare workflow? If you have
ios/
orandroid/
directories in your project, the answer is bare!bare
What platform(s) does this occur on?
Android, iOS, Web
SDK Version (managed workflow only)
No response
Environment
expo-env-info 1.0.3 environment info:
System:
OS: macOS 12.4
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 14.17.3 - ~/.nvm/versions/node/v14.17.3/bin/node
Yarn: 1.22.18 - ~/.nvm/versions/node/v14.17.3/bin/yarn
npm: 8.7.0 - ~/.nvm/versions/node/v14.17.3/bin/npm
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8512546
Xcode: 13.4/13F17a - /usr/bin/xcodebuild
npmPackages:
expo: ~45.0.0 => 45.0.5
react: 17.0.2 => 17.0.2
react-dom: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-web: 0.17.7 => 0.17.7
Expo Workflow: bare
Reproducible demo
https://github.com/ngregory-rbi/my-app
Footnotes
installed, or at least enforced by
https://exp.host/--/api/v2/versions/latest
which currently defines"@types/react": "~17.0.21"
as a requirement for Expo 43, 44, and 45. (https://semver.npmjs.com/ confirms that will result in the version 17.0.45) ↩installed by
"@types/react-native": "~0.66.13"
in thepackage.json
for the app. ↩installed by
"@types/react": "*"
in thepackage.json
for@types/react-native@0.66.18
. ↩The text was updated successfully, but these errors were encountered: