How to downgrade React version 16 to 15

How to downgrade React version 16 to 15

Since the manufacturer released the first React version, React has gone through many upgrades and innovations. However, besides the advantages, the upgrade can also cause some discomfort for users and some people want to go back to using the previous version. In this article we will guide you to answer the question “How to downgrade React version 16 to 15“. Let’s follow along!

Check the installed version

Before we get to the main body of this post, we’ll cover some information you might need. To save time in upgrading/downgrading versions, you need to know for sure which version you are using. There is a simple and fast way to check that is to use the command line ‘npm view react version, the results will let you know the version of React is installed on the machine like below:

npm view react version
# 16.13.1

How to downgrade React version 16 to 15

Here we are going to show you several methods to downgrade React version 16 to 15. Let’s have a look and choose the method that is right for you.

Method 1: Modify the package.json file

To downgrade React 16 to 15, you can completely manually adjust it by changing the package.json file in your library. Here are the steps

  Step 1: Access the file package.json

  Step 2: In the dependencies, find and replace the versions of react and react-dom to 15.6.0, like this:

 "dependencies": {
     "react": "^15.6.0",
     "react-dom": "^15.6.0",
     ...
   },

Step 3: Finally, run the command line npm install to reinstall the version. Thus, the React version has been downgraded from 16 to 15. You can check the version by running the command introduced above.

Method 2: Remove version 16 and install version 15

With this method you can directly install the version you want (in this case version 15).

First of all,  you need to delete the version that is installed on the machine using the command line:

npm uninstall react

Now you can start installing the version you use, we have this command line:

npm install [email protected]

Method 3: 

Alternatively you can also use the command line below to downgrade:

Conclusion

Above is the best key to solve the examination “How to downgrade React version 16 to 15”. We are confident that with this information, you will be able to make the best method of your own and get the relevant information about this topic. If you have any further questions, you can leave your comments in the Comments section. I hope you have a productive day with your subject. See you in the next session!

Maybe you are interested:

Leave a Reply

Your email address will not be published. Required fields are marked *