{

How to get a version of React running at runtime in the browser?


This article explains multiple ways to get react versions used in React applications. The first way, using the package.json file in an application. The second way, use React. version from importing React module The third way, using the REACT_DEVTOOLS_GLOBAL_HOOK object in the browser console of React developer tools.

How to get react version displayed in the browser used in the Application

There are multiple ways to know the react version in code and from the terminal.

  • using package.json

Open package.json file, check dependencies section, It contains react dependency as given below with version. 17.0.2 is the react version used in my application

  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",

  },
  • React module

React module imported and used as a global scope, This gives react version.

import React from 'react';

function App() {
  return (
    <div className="App">

      <div>React Version - {React.version}</div>,

    </div>
  );
}

export default App;
  • With React Developer tools,

First, Install react developer tools installed on the browser, You can run the below code in the console browser to get react version running.

__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers.get(1).version

Conclusion

Learned multiple ways to find react version running in react application with examples.

THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.