{

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 Application. 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 REACT_DEVTOOLS_GLOBAL_HOOK object in the browser console of React developer tools.

How to get react version displayed in the browser used in 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

ReactJS Append variables with strings, jsx state and prop concatenate html

How to display the content of a JSON file in React with example

Reactjs Fix Must call a super constructor in derived class before accessing this

How to change default port in React with create-react-app command?

How to create an react typescript application | Create-react-app typescript application

How to handle broken images in React | fallback for broken images

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