mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-13 22:43:59 +08:00
Validate that JS and Native code versions match for RN releases
Summary: Basic implementation of the proposal in #15271 Note that this should not affect facebook internally since they are not using OSS releases. Points to consider: - How strict should the version match be, right now I just match exact versions. - Wasn't able to use haste for ReactNativeVersion because I was getting duplicate module provider caused by the template file in scripts/versiontemplates. I tried adding the scripts folder to modulePathIgnorePatterns in package.json but that didn't help. - Redscreen vs. warning, I think warning is useless because if the app crashes you won't have time to see the warning. - Should the check and native modules be __DEV__ only? **Test plan** Tested that it works when version match and that it redscreens when versions don't before getting other errors on Android and iOS. Closes https://github.com/facebook/react-native/pull/15518 Differential Revision: D5813551 Pulled By: hramos fbshipit-source-id: 901757e25724b0f22bf39de172b56309d0dd5a95
This commit is contained in:
committed by
Facebook Github Bot
parent
9b3cc30357
commit
1af645b2fd
@@ -38,6 +38,7 @@ public class AndroidInfoModule extends BaseJavaModule {
|
||||
constants.put("Version", Build.VERSION.SDK_INT);
|
||||
constants.put("ServerHost", AndroidInfoHelpers.getServerHost());
|
||||
constants.put("isTesting", "true".equals(System.getProperty(IS_TESTING)));
|
||||
constants.put("reactNativeVersion", ReactNativeVersion.VERSION);
|
||||
return constants;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ android_library(
|
||||
name = "systeminfo",
|
||||
srcs = [
|
||||
"AndroidInfoModule.java",
|
||||
"ReactNativeVersion.java",
|
||||
],
|
||||
exported_deps = [
|
||||
":systeminfo-moduleless",
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @generated by scripts/bump-oss-version.js
|
||||
*
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.systeminfo;
|
||||
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ReactNativeVersion {
|
||||
public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
|
||||
"major", 0,
|
||||
"minor", 0,
|
||||
"patch", 0,
|
||||
"prerelease", null);
|
||||
}
|
||||
Reference in New Issue
Block a user