How to Upgrade React Native Version 0.66.3 to 0.70.6? - react-native

Currently, my project running on the 0.66.3 version I need to upgrade to react native version 0.70.6. So I have used to following command
npx react-native upgrade
After running this command showing some error I have attached a screenshot please refer.
I am also trying the manual way using react native helper but some files are not available in my project.
so anyone please tell me how I will upgrade my project version?
After Run npx react-native run-android my build was created successfully but 3 errors showing in the metro bundler. I have attached a screenshot of the metro bundler error.

you can specify a React Native version and pass it as an argument:
npx react-native upgrade 0.70.6

you can also refer this official documentation for this
& it will also helps you if you got any error.
https://reactnative.dev/docs/upgrading

I found by changing react-native - index.js and react-native/Libraries/Text - index.js
Follow this link for output:
https://github.com/facebook/react-native/commit/3f629049ba9773793978cf9093c7a71af15e3e8d
Don't know whether it is the right way or not....

Since upgrading an application can break functionality in your app if you do not know what is needed to be changed. the upgrade is tells you to visit the pages to go through and see what has changed throughout the upgrading process.
Other as that I am just needing more information regarding to what is not working. Since upgrading is more as just running a command, its about reading the documentation and see what part is missing and what they replaced the files with. The missing files could be straight-out deprecated and not working with the new version.
As always check the debugger and read every message throughout and visit all links given and see the documentation regarding the upgrade differences, find out if there are any log files you could look at, and talk with people in your company / group of react-native about this.
"Some files are not available in my project"
This part might just be able to google and see if this is still supported or not in the version it could be phased out, or not supported in the version. that's where versioning comes in to play.
I am unsure what files and which libraries are deprecated based on your Opening Post, this needs more information, to help us, help you.

Related

Output: "[Warning] Could not find workspace while activating"

I'm getting this error when opening VS Code. Does anyone know what it means? I've done some research but didn't get any relevant information :(
I've tried creating a workflow to see if the error disappeared, but it didn't.
It seems that react native is asking for a workspace to start but is it asking that in the first place? Can I disable react native from running when opening VS Code?
The folder opened when the screenshot above was taken was the folder it opens by default, I believe it's the mac "home" personal folder, and I have a folder called "git" inside of it, with all projects.
Given the date of this posting (2023-02-07), you're probably on version 1.10.0 of the extension. This sounds like this bug report in the microsoft/vscode-react-native GitHub repo: [Bug] Extension activating when it shouldn't #1891.
A fix is coming in version 1.10.1.
But it is taking some time and has not been release yet at the time of this writing 2023-01-31:
we're facing some problems in the last release process, recently we're waiting for new publishing PAT access to republish 1.10.1 again, maybe it will publish on marketplace on next week. We have nightly version for extension in marketplace as well, maybe you can use it now.
For now, you can try installing the nightly version.
Also, note from the extension's readme documentation:
Before going any further make sure that you:
have a working React Native environment.
have the emulator utility available in your PATH if you're developing Android applications.
[...]
Got it, this annoying log came from React Native Tools extension. They specify the requirements in the docs:
In my case, I don't have a specific React Native environment or the emulator PATH is not right.

React-Native, React-Native-Web and React-Navigation/Stack

Has anyone been able to get React-Native 0.7, React-Native-Web and React-Navigation/Stack 6.2.3 to work on web? I have a small app working on iOS and Android which I am trying to enable on web too. iOS and Android portion work fine and using metro.
However, webpack build continues to error out with "Module parse failed: Unexpected token" on the NavigationContainer.
I tried searching both react-native-web and react-navigation Issues on their respective GitHub Repositories. However, could not find something to solve my issue. Also tried modifying webpack.config with several different configurations/loaders.
Used links below as a reference too:
https://arry.medium.com/how-to-add-react-native-web-to-an-existing-react-native-project-eb98c952c12f
https://gist.github.com/skabbes/0bfa0a969aac8ec13f716dda1ad2ab43
Yes, it happens that I maintain a library that does just that: creates a bare React Native app that also runs on the web: 🌒 Luna - https://github.com/criszz77/luna
Here is the live example: https://criszz77.github.io/luna/
You can find more on the wiki page about how it's implemented and you can also implement it by yourself: https://github.com/criszz77/luna/wiki
By using react-scripts, you don't have to handle webpack, babel and other hard configs by yourself.
It currently doesn't run on 0.7 (didn't have time to make the update), but it's in plan to support all the latest versions of course ASAP.
EDIT: Updated to 0.70.3 🎉

'NativeReanimated' could not be found. Verify that a module by this name is registered in the native binary

This is my Code which is showing this error . Here I am trying to make a Drawer-navigation
This is the error showing , I am doing this in react-native.
It seems you might have missed some installation / setup steps for react-navigation.
Please check this section in the docs: https://reactnavigation.org/docs/getting-started#installing-dependencies-into-a-bare-react-native-project
If you have already installed the packages listed there (notably react-native-reanimated), perhaps you have not installed the native dependencies. This is important on iOS - run npx pod-install in your project root, and then build the app again (hot reload will not be enough).

Upgrading react native to latest version

I have an application which runs on react-native 0.49.3
I want to upgrade to the latest version which is v0.57.4.
Should I incrementally update it? For example 0.49 -> 0.50 -> 0.51 etc
Or I can just update it to to the latest version?
Do you suggest using react-native-git-upgrade or rn-diff?
My advice is to upgrade to the latest version. There will be enough dependency issues anyway so you're best dealing with them only once.
From the React Native upgrade page
(https://facebook.github.io/react-native/docs/upgrading)
you can run:
npm install -g react-native-git-upgrade
npm install -g #react-native-community/cli
react-native-git-upgrade
UPDATE 2:
The new command is
npx react-native upgrade
but I believe this is best for upgrading from more recent versions. If you have older versions, the following upgrade process still applies.
UPDATE:
I've never had a problem before with upgrades, but recently joined a project where we upgraded from an old copy of React Native 0.44.3 to a newer version (first to 0.57.8, then to 0.55.4, then to 0.58.3 while struggling with stability) and discovered that it's not always as easy as running those commands. Be warned that this could be a long, tedious process, especially if you have not upgraded regularly and have a long gap between upgrades. In this case, it was 18 months since they had upgraded.
First, there have been changes to the upgrade process itself (react-native upgrade, to now react-native-git-upgrade) itself. So, if you're using a version that's a year old or more there could be some manual discrepancies that you'll have to go through. Some are spelled out after running the react-native-git-upgrade command, and some are not. I was amazed at the number of people on Stack Overflow going through the same undocumented circular issues of a seemingly innocent upgrade. I was not expecting that. I'd be OK with Facebook not adding any features for 6 months and simplifying the upgrade process before moving on.
Second, make sure your version of React Native uses the right dependencies. Later versions of the upgrade tool (react-native-git-upgrade) try to account for this, but double check at https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md to see if the version of RN that you're upgrading to requires a specific dependency. Some do while others do not.
Next, library hades is real, depending on how big your project is. In our case, several modules in use in our 0.44.3 version have now been deprecated or no longer maintained or even work differently with the later versions of RN. I didn't consider this enough when starting this process. This caused several instances of code rewrite just to upgrade!! Yikes!
Also, just as some versions of React Native require specific versions of dependencies, other modules require specific versions of some dependencies. Worse, sometimes these are incompatible and conflicting versions, of various libraries. Save some time and write a user story or two to account for this. Go through every module you're using and see if there are any compatibility statements on their GitHub page. Some Readme files will tell you to use certain versions of their module with certain versions of React Native. Others won't and you may find out later there are requirements. But even going through this process and anticipating issues, you'll thank yourself later.
Once you're up to date and stable, consider upgrading regularly to minimize the upgrade nightmare that I just went through.
You will need #react-native-community/cli to upgrade to the latest version of react-native, sadly not mentioned anywhere.
npm install -g #react-native-community/cli
Install react-native-git-upgrade
npm install -g react-native-git-upgrade
Now go to your project.
cd your-react-native-project
Now you can run the upgrade command.
react-native upgrade
Just change the path to the project for which you want to upgrade the react native version and then run this command:
react-native upgrade
and after running this command you will see some questions. Type n to discard the change to that file or type y if you want to modify that file.
It will automatically install the latest version of react-native for your project.
More info at:
https://facebook.github.io/react-native/docs/upgrading
OR
You can upgrade react native version by this simple step:
1- Just go to package.json file of your project
2- After that, look for these lines
"dependencies": {
"react-native": "0.57.8",
}
3- Change the react-native version to any version that you want to upgrade to in "dependencies".
4- After this run npm install and react native version will be upgraded for your project.
I would recommend using this tool (upgrade helper) which allows you to compare your current react native version and latest react native version.
Also, It's good to upgrade react-native frequently to stay up to date with the latest version and make the upgrade process easy.
https://react-native-community.github.io/upgrade-helper/
I recommend visiting this page: https://github.com/react-native-community/rn-diff-purge
because you can see the list of exactly what changes in each version. I find it's simpler to manually change config settings after starting from your version that is proven to work properly via react-native run-android and react-native run-ios.
It sounds like a horrible task, but it's not very difficult for your fingers or brain to remove red lines and add green lines--at least compared to alternatives such as Googling to sort out horrific error messages in the Android/iOS build systems.
I also believe that it's a good idea to manually change config settings for example going from 0.44 to 0.59 because you get more of an opportunity to see exactly what is changing in each version. You'll see the changes are reasonable and generally have bearing on fostering future automation and increasing the build systems' robustness and aversion to breakage.
Additionally, changes were implemented in RN 0.59 that makes react-native upgrade better, and in addition to my additional statement, the whole 0.59 release is pretty massive and important for future: http://facebook.github.io/react-native/blog/#upgrading-to-059
I'm not even going to talk about react-native upgrade or react-native-git-upgrade because I find those to be generally a source of nightmares especially if you get into react-native unlink and react-native link.
You can update to the latest version directly, I'd recommend to do it with react-native-git-upgrade, but do be careful to read the update release notes on the versions up to yours, they have some notes about things you should do manually that the upgrade will not. You can find the notes here: https://github.com/facebook/react-native/releases
The notes are usually on top in the changelogs, I know the latest releases had some of those and gave me some work to update from 0.54 recently so be aware.
In case there are changes then you can either update them manually by copying and pasting from the changes in the page or you can do it with the React Native CLI upgrade command by running:
npx react-native upgrade
As explained in the docs: https://reactnative.dev/docs/upgrading
react-native upgrade
npm i react-native#{{VERSION}}
npm i react#{{VERSION}}
https://facebook.github.io/react-native/docs/upgrading
https://react-native-community.github.io/upgrade-helper/?from=0.59.9&to=0.61.0
Even with using the new upgrade helper https://react-native-community.github.io/upgrade-helper/ I still run into a bunch of issues and it takes forever to debug them. The best and most reliable way I have found to upgrade after react-native core teams make big changes like adding fast-refresh or flipper that involves a lot of xcode related changes it just start from scratch.
create new repo
npx react-native init newProject
STEP 1 -
make sure the new app runs properly so you know if you have an xcode/react native package issues that need to be upgraded. I know I ran into an xcode issue that forced me to upgrade to a new mac os version.
STEP 2 - pull up old projects xcworkspace or xcodeproj if you are not using any custom pods and just copy over the important stuff like the signing stuff and potentially any custom build scripts you have. I have custom fonts so I pull that over
STEP 3 - copy over app specific code, think app folder or src and any files that live in the root of your project.
STEP 4 - Run npm install and pod install if you have custom pods
STEP 5 - Important not to just paste over the App.js/tsx file but instead just render a simple view with text in it. If your app will run here then it means all your npm/pods are configured properly. Usually I run into a bunch of error in this step which require me to upgrade npm/pods to new version to deal with breaking changes in react-native
STEP 5.a - One by one add in each line from your original App.js/tsx file and testing if anything breaks. Sometimes its useful to reset your metro cache in between changes and removing the build folders inside of ios and android during debugging. Also its very helpful to use the chrome debugger stop on exception functionality here so you know where the issues are coming from
STEP 6 - copy over .git folder from previous project that lives in the root of your project so you can keep your version history or just create a new git repo if you dont care about this.
I have upgraded RN to newer versions in a couple of hours using this method multiple times. I typically write myself some notes while I do it to speed to up the process next time I need to upgrade. Good Luck!
npx react-native upgrade
Should do all the work for you.
use cammand npx react-native upgrade
if you are facing errors it's due to some deprecated packages.So comment all pages and in route and step by step add your pages and replace your deprecated packages with new .
And also use this update helper 'https://react-native-community.github.io/upgrade-helper/'
You can Upgrade with 4 simple step
npm install -g #react-native-community/CLI
npm install -g react-native-git-upgrade
cd your-react-native-project
react-native upgrade
Thanks :)

Will react native be supported by windows?

will react native be supported by windows os?Or linux . I don't own a mac so i was wondering if facebook plans to release react native for windows or linux. i don't want to run virtual machine because it's too much of a hassle.
I had successfully run the react-native on windows with a few hack.
The gist is here gist
Windows support would be awesome but cannot promise an ETA. We'd be happy to review pull requests that will make the CLI work on Windows.
You could skip the CLI and start with the Sample app from examples, build it with Gradle and start the packager manually using node node_modules/react-native/packager/packager.js.
Discussion here: https://github.com/facebook/react-native/issues/2693
This is not official support but I figured out how to get things working on Windows in a way that allows you to use the react-native CLI as documented without having to modify the source code.
The main issue that I encountered was with the hardcoded references to sh in React Native's packager. I solved this by adding Cygwin's bin directory to my path. Others have provided solutions for this where they modify the source code to work on Windows but I'd prefer not to go that route in order to ease updating to newer versions of React Native.
The other two catches where having to enable virtualization in my BIOS in order to get HAXM support and having to load the debugger page manually.
I wrote up some notes on the complete process here and intend to keep this up to date with future release of React Native:
http://davidanderson.io/2015/10/18/a-step-by-step-guide-to-react-native-on-windows/