I am having some trouble with upgrading my react-navigation from v3 to v5. I keep running into this error, at first I thought it was a bug but I am not finding any other complaints online about it. To be 100% sure the old versions weren't causing any issues, I completely uninstalled all react-navigation and started from scratch with v5. I am still getting an error with the index file. It doesn't appear to understand the typescript...is this a known bug? Is there another step I need to take that is not in the documentation about installing Typescript?
UPDATE: ./types files is not compiling correctly...it doesn't seem to recognize NavigationState or ActionHelpers...is this a bug? Has anyone seen this before?
UPDATE 2 i am running on RN V0.59 so I am thinking there could be a dependency issue. I am upgrading to V0.62.2 and seeing if the issue persists
https://reactnavigation.org/docs/getting-started
SyntaxError: /Users/myusername/myprojectname/node_modules/@react-navigation/stack/src/index.tsx: Unexpected token (51:12)
49 | * Types 50 | */
51 | export type { | ^ 52 | StackNavigationOptions, 53 | StackNavigationProp, 54 | StackHeaderProps,
If you use TypeScript, do this:
node_modules
and the lock file (yarn.lock
or package.lock
)yarn cache clean
or npm cache clean
.yarn
or npm install
.yarn react-native start --reset-cache
.yarn react-native run-android
.If you don't, then follow these steps:
yarn add --dev @babel/core@^7.9.0 @babel/runtime@^7.9.0
.emulator/phone
.yarn react-native start --reset-cache
.yarn react-native run-android
.If that did not work, go to android/
, and run gradlew clean
or ./gradlew clean
, remove the apk from you phone and rerun yarn react-native run-android
.