In this tutorial, You will learn several methods to check the version of the React js application in cmd, file, and browser console.
How to Check React JS Application Version?
Here are some methods on check version of installed react js applications:
1 Method – Check the package.json file
When you create a new React project, the version number of React is automatically included in the project’s package.json file. To check the version of React, open package.json file and look for the line that says “react” under the dependencies section:
{
...
...
...
"name": "react-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},
...
...
...
}
2 Method – To Check React Version by visiting the react.development.js
The second method is also similar to the first method, Open react.development.js file. Which you will find inside node_modules/react/cjs/ directory:
/** @license React v16.13.1
* react.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
3 Method – To Check React Version using App.js
In this, you have to open app.js file, and add the following code to it:
import React from 'react'
function App() {
return (
<div className="App">
Here is the Latest React version: <strong>{React.version}</strong>
</div>
);
}
export default App;
After this, you have to go to the terminal and execute the command given below. Which will start your React JS app:
npm start
4 Method – Check to react version in terminal ubuntu using Command Line/CMD/Terminal
The fourth way is very simple, run the following command to check version on cmd or terminal window:
npm view react version
Now you will see the version of React app installed on your terminal.
5 Method – Check the browser console
Open your web application in a browser and open the browser console, and type the following command:
React.version
Conclusion
In conclusion, checking the version of React being used in your web application is an important step in maintaining and updating your application.