Every line of 'how to check react version' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
46 function reportOnReactVersion(node) { 47 if (!versionUtil.testReactVersion(context, '16.2.0')) { 48 context.report({ 49 node, 50 message: 'Fragments are only supported starting from React v16.2. ' + 51 'Please disable the `react/jsx-fragments` rule in ESLint settings or upgrade your version of React.' 52 }); 53 return true; 54 } 55 56 return false; 57 }
8 export function isReactVersion13() { 9 var version = React.version.split(".")[1]; 10 return version === "13"; 11 };
90 export function getInstalledPropTypesVersion(): number { 91 if (installedVersion) { 92 return installedVersion; 93 } 94 95 try { 96 // eslint-disable-next-line global-require 97 installedVersion = parseFloat(require('prop-types/package.json').version); 98 } catch { 99 // Swallow 100 } 101 102 return installedVersion; 103 }
7 function getReactNativeVersion() { 8 if (!reactNativeVersion) { 9 reactNativeVersion = minimist(process.argv.slice(2)).version || ''; 10 11 if (!reactNativeVersion) { 12 reactNativeVersion = require('../maps/misc')['max-support-rn']; 13 } 14 } 15 16 return reactNativeVersion; 17 }
4 export default function getReactNativeVersion( 5 cwd: string 6 ): semver.SemVer | undefined { 7 const { version } = require(path.join( 8 cwd, 9 'node_modules/react-native/package.json' 10 )); 11 12 const parsedVersion = semver.parse(version); 13 if (!parsedVersion) { 14 return undefined; 15 } 16 17 return parsedVersion; 18 }
33 function checkProps (version, props, oldProps) { 34 Object.keys(oldProps).forEach((oldProp) => { 35 if (typeof props[oldProp] !== 'undefined') { 36 const newProp = typeof oldProps[oldProp] === 'string' 37 ? oldProps[oldProp] 38 : null 39 40 warning( 41 false, 42 '%s was deprecated in %s%s', 43 oldProp, version, (newProp ? ` use ${newProp} instead` : '') 44 ) 45 } 46 }) 47 }
47 checkVersion() { 48 console.log(`[VersionChecker] Checking if a new version is available...`); 49 this.getLatestVersion() 50 .then(latestVersion => { 51 const currentVersion = this.currentVersion; 52 this.lastVersionCheck = moment().format(); 53 54 // Is current version older than the latest version 55 if (semver.lt(currentVersion, latestVersion)) { 56 console.log(`[VersionChecker] New version ${latestVersion} is available!`); 57 this.pushNewVersionStatus(latestVersion); 58 return; 59 } 60 61 console.log(`[VersionChecker] Already on the latest version ${latestVersion}.`); 62 const StatusManager = require('../status/StatusManager'); 63 64 if (StatusManager.getStatusByKey(this.statusKey)) { 65 StatusManager.removeStatus(this.statusKey); 66 } 67 }) 68 .catch(() => { 69 console.log(`[VersionChecker] Couldn't fetch the latest version of CIMonitor.`); 70 }); 71 }
72 checkVersion() { 73 this.log.info("Checking Package Version for Updates..."); 74 return new Promise((resolve) => { 75 childProcess.exec( 76 `npm view ${packageFile.name} version`, 77 (error, stdout) => { 78 const newVer = stdout && stdout.trim(); 79 if (newVer && compareVersions(stdout.trim(), packageFile.version) > 0) { 80 this.log.warn(`---------------------------------------------------------------`); 81 this.log.warn(`NOTICE: New version of ${packageFile.name} available: ${newVer}`); 82 this.log.warn(`---------------------------------------------------------------`); 83 resolve(true); 84 } else { 85 this.log.info(`INFO: Your plugin version is up-to-date`); 86 resolve(false); 87 } 88 } 89 ); 90 }); 91 }
70 async function checkVersion() { 71 const version = getVersion(); 72 const hrTime = process.hrtime(); 73 const ctime = hrTime[0] * 1000 + hrTime[1] / 1000000; 74 const ltime = settings.get('lastAccessTime'); 75 const lastAccessVersion = getLastAccessVersion(ctime, ltime); 76 if (lastAccessVersion && (version == lastAccessVersion)) { 77 //version matched with cached version 78 return; 79 } 80 81 const pv = await latestVersion('@here/cli'); 82 if (pv > version) { 83 console.log("herecli('" + version + "') is out of date. Latest version is " + pv + ". Use command 'npm install -g @here/cli' to update to the latest version"); 84 process.exit(1); 85 } 86 // version matched with current version. We are up to date 87 settings.set('lastAccessVersion', pv); 88 settings.set('lastAccessTime', ctime); 89 }
322 function printVersionsAndExit(reactNativePackageJsonPath) { 323 console.log(`react-native-cli: ${require('./package.json').version}`); 324 try { 325 console.log(`react-native: ${require(reactNativePackageJsonPath).version}`); 326 } catch (e) { 327 console.log( 328 'react-native: n/a - not inside a React Native project directory', 329 ); 330 } 331 process.exit(); 332 }