Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get react native version from JavaScript?

Tags:

react-native

Is there any way to get react-native`s version through javascript code? Something like this

import {
    Platform
} from 'react-native';
let version = Platform.version;
like image 740
magicismight Avatar asked Jan 18 '16 08:01

magicismight


2 Answers

These code can do the trick.

const PACKAGE = require('YOUR_PROJECT_PATH/node_modules/react-native/package.json');
const version = PACKAGE.version;
like image 56
magicismight Avatar answered Sep 28 '22 04:09

magicismight


There is another way to do the same thing.

const ReactNativeVersion = require('./node_modules/react-native/Libraries/Core/ReactNativeVersion');
console.log(ReactNativeVersion.version.major + ReactNativeVersion.version.minor);
like image 40
jarora Avatar answered Sep 28 '22 06:09

jarora