Home  »  CodeSnippets   »   How to Get the React Version With npm or Script

How to Get the React Version With npm or Script

Posted: February 8, 2022 | by Site Host

You can use this command in your terminal to view which version of React is used for your app.

$ npm view react version
$ npm view react-native version

From with React app:

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>

<script>
   const REACT_VERSION = React.version;

   ReactDOM.render(
     <div>React version: {REACT_VERSION}</div>,
     document.getElementById('root')
   );
</script>

Add this to your HTML body element:

<div id="root"></div>

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Share it!

See also  How to Stop a Background Image From Repeating in CSS