How to Downgrade React Version?

If you want to downgrade Reaction version either from 18 to 17 or 17 to 16 or 18 to 16 etc. because of any reason like your existing React project don’t support new package of React 18.

You can easily downgrade React version. Lets read below to understand how you can downgrade React Version.

To downgrade React version either update dependencies in package.json or using command Line using npm install.

How to Downgrade React Version from 18 to 17?

Method 1: By Changing Dependencies under package.json file.

To downgrade React version from 18 to 17,

  • First open your package.json file.
  • Search For react and react-dom under dependencies
  • Under dependencies, change both package versions to 17.0.0
  • Now, run npm install

After performing above steps your react version will be downgraded from 18 to 17.

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

After that run

npm install

Method 2: Using Command Line : First Uninstall then Install

Using this method, first you have to uninstall the react then install the specific version of React using npm in command line.

First Uninstall React

npm uninstall react

Now, Install React version 17 using npm

npm install react@17.0.0

Method 3: Using Command Line: With out Uninstalling React

npm install --save react@17.0.0 react-dom@17.0.0

How to Downgrade React Version from 17 to 16?

To downgrade React version from 17 to 16 either update dependencies in package.json or using command Line using npm

npm install --save react@16.0.0 react-dom@16.0.0

How to Downgrade react-router-dom?

To downgrade react-router-dom into v5.20 then use npm install react-router-dom@5.2.0, your React version will be downgraded.

npm install react-router-dom@5.2.0