{

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.





Related posts

Basic React Interview questions and answers

Best ways to add an element to an array in React state with examples

Difference between Development and Production Builds in React

Difference between pureComponent and component in React

Difference between super and super props in React constructor class?

Fixing an error You are running create-react-app 4.0.3, which is behind the latest release (5.0.0) in React

Getting started with ReactJS Bootstrap Tutorials with examples | reactstrap tutorials