. Advertisement .
..3..
. Advertisement .
..4..
Your React has updated to version 17, whose features you do not like. We guess you would love to learn how to downgrade React version 17 to 16. Here is great news: you have come to the right place!
What Is React?
React is a development library with a JavaScript-based system run by open-source developer communities and Facebook.
Most refer to React as one giant library rather than an actual language. Still, it thrives in web developments. Since its first launch in 2013, React has been among the most popular frontend libraries tailored for web development.
React provides extensions for whole application architecture support – aside from mere UI. React Native and Flux are cases in point.
What Are The Differences Between React 16 and React 17?
React 17 brings in no major changes. Still, you may realize some minor adjustments.
For starters, our “onScroll” event does not bubble up from “child” to “parent” components anymore. Also, the “onBlur” and “React onFocus” events have started to adopt native “focusout” and “focusin”.
Secondly, React’s capturing phase events (such as the “onClickCapture” turn to real browser listeners for capture phases.
Furthermore, its “onEffect” cleanup functions always run asynchronously. Let’s take an example: suppose we have an unmounting component. Then whatever cleanup that runs after our screens has been upgraded.
How to Downgrade React Version 17 to 16?
Method 1: Use Yarn or NPM Install
Let’s say you use yarn/npm (or other managers for node packages). Chances are all the dependency versions will be listed in the “package.json”.
We suggest you search the “react-dom” and “react” packages beneath dependencies or devDependencies, before replacing them with 16.13.0.
Once done, run “npm install” or “yarn” or any package manager. That should be sufficient to downgrade the React from 17 to 16.
And what if other packages are not compatible with your React 16? Then it is possible to downgrade these compartments as well.
Method 2: Use Command Lines
Once you have updated the package.json dependencies, let’s run “NPM install” to achieve the downgrades. Another way is to perform a command line like this:
Example (Solution 2):
npm install --save [email protected] [email protected]
Method 3: Use Redux Devtools
What if the two previous solutions fail to work? You can always turn to this approach. It is practical and applicable in certain cases and might help you tackle this issue! We understand that you might feel unsure, but it does not hurt to try, right?
Here is what we have done:
Example (Solution 3):
npm uninstall react-redux npm uninstall redux
npm install --save [email protected] [email protected]
npm install redux npm install react-redux
npm install --save-dev redux-devtools
FAQs
1. How Can I Know Which React Version I Am Using?
Let’s open your console and operate “window. React. version”. Refer to these steps to check your current React version and identify “react-dom” and “react”.
- Step 1. Navigate to “DeveloperTool” from your browser.
- Step 2. Navigate to “Source Tab”.
- Step 3. Check the file “appName. js”.
- Step 4. Insert “react-dom” and “react” into the search bar. It will show the name of the version used by your “react-app”.
2. Is It Possible to Downgrade My React 18 to React 16?
Yes, of course! You can take similar steps as our above instructions. Search the “react-dom” and “react” packages under dependencies or devDependencies, before replacing them with 16.13.0. Next, run “yarn” or “npm install” or any package manager to downgrade your React to 16.
Conclusion
This article has shown you how to downgrade React version 17 to 16. For more issues on downgrades (such as downgrading Python from 3.10 to 3.9), you can browse our website for more info.
Read more:
Leave a comment