Skip to content

Commit f87c716

Browse files
ethansharM-i-k-e-l
andauthored
Migrate to RN62 (#837)
* Update general files * Complete migration to rn62 for iOS * RN 62 Android migration changes * Almost complete migration to RN 62 on Android * Fix copy-paste bug * Fix Android native libs * Fix snapshot tests after RN62 changes Co-authored-by: Miki Leib <[email protected]>
1 parent 32b3cce commit f87c716

File tree

21 files changed

+402
-480
lines changed

21 files changed

+402
-480
lines changed

.flowconfig

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
1010

11-
; Ignore duplicate module providers
12-
; For RN Apps installed via npm, "Libraries" folder is inside
13-
; "node_modules/react-native" but in the source repo it is in the root
14-
.*/Libraries/react-native/React.js
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
1514

16-
; Ignore polyfills
17-
.*/Libraries/polyfills/.*
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
1817

19-
; Ignore metro
20-
.*/node_modules/metro/.*
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
2120

2221
[include]
2322

2423
[libs]
25-
node_modules/react-native/Libraries/react-native/react-native-interface.js
24+
node_modules/react-native/interface.js
2625
node_modules/react-native/flow/
2726

2827
[options]
@@ -31,39 +30,45 @@ emoji=true
3130
esproposal.optional_chaining=enable
3231
esproposal.nullish_coalescing=enable
3332

34-
module.system=haste
35-
module.system.haste.use_name_reducers=true
36-
# get basename
37-
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
38-
# strip .js or .js.flow suffix
39-
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
40-
# strip .ios suffix
41-
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
42-
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
43-
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
44-
module.system.haste.paths.blacklist=.*/__tests__/.*
45-
module.system.haste.paths.blacklist=.*/__mocks__/.*
46-
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
47-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
33+
module.file_ext=.js
34+
module.file_ext=.json
35+
module.file_ext=.ios.js
4836

4937
munge_underscores=true
5038

51-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
52-
53-
module.file_ext=.js
54-
module.file_ext=.jsx
55-
module.file_ext=.json
56-
module.file_ext=.native.js
39+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
40+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
5741

5842
suppress_type=$FlowIssue
5943
suppress_type=$FlowFixMe
6044
suppress_type=$FlowFixMeProps
6145
suppress_type=$FlowFixMeState
6246

63-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
64-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
65-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
47+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
6649
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
6750

51+
[lints]
52+
sketchy-null-number=warn
53+
sketchy-null-mixed=warn
54+
sketchy-number=warn
55+
untyped-type-import=warn
56+
nonstrict-import=warn
57+
deprecated-type=warn
58+
unsafe-getters-setters=warn
59+
inexact-spread=warn
60+
unnecessary-invariant=warn
61+
signature-verification-failure=warn
62+
deprecated-utility=error
63+
64+
[strict]
65+
deprecated-type
66+
nonstrict-import
67+
sketchy-null
68+
unclear-type
69+
unsafe-getters-setters
70+
untyped-import
71+
untyped-type-import
72+
6873
[version]
69-
^0.92.0
74+
^0.113.0

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.pbxproj -text
1+
# specific for windows script files
2+
*.bat text eol=crlf

android/app/build.gradle

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ android {
2525
applicationId "com.rnuilib"
2626
minSdkVersion rootProject.ext.minSdkVersion
2727
targetSdkVersion rootProject.ext.targetSdkVersion
28-
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative60"
2928
versionCode 1
3029
versionName "1.0"
3130
}
@@ -57,6 +56,14 @@ android {
5756
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
5857
}
5958
}
59+
60+
packagingOptions {
61+
pickFirst "lib/armeabi-v7a/libc++_shared.so"
62+
pickFirst "lib/arm64-v8a/libc++_shared.so"
63+
pickFirst "lib/x86/libc++_shared.so"
64+
pickFirst "lib/x86_64/libc++_shared.so"
65+
}
66+
6067
// applicationVariants are e.g. debug, release
6168
applicationVariants.all { variant ->
6269
variant.outputs.each { output ->
@@ -75,7 +82,21 @@ android {
7582

7683
dependencies {
7784
implementation fileTree(dir: "libs", include: ["*.jar"])
85+
//noinspection GradleDynamicVersion
7886
implementation "com.facebook.react:react-native:+" // From node_modules
87+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
88+
89+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
90+
exclude group:'com.facebook.fbjni'
91+
}
92+
93+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
94+
exclude group:'com.facebook.flipper'
95+
}
96+
97+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
98+
exclude group:'com.facebook.flipper'
99+
}
79100
implementation project(':react-native-navigation')
80101
implementation project(':react-native-ui-lib')
81102
implementation 'com.facebook.fresco:fresco:2.0.0'
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5+
* directory of this source tree.
6+
*/
7+
package com.rndiffapp;
8+
9+
import android.content.Context;
10+
import com.facebook.flipper.android.AndroidFlipperClient;
11+
import com.facebook.flipper.android.utils.FlipperUtils;
12+
import com.facebook.flipper.core.FlipperClient;
13+
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14+
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15+
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16+
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17+
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18+
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19+
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20+
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21+
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22+
import com.facebook.react.ReactInstanceManager;
23+
import com.facebook.react.bridge.ReactContext;
24+
import com.facebook.react.modules.network.NetworkingModule;
25+
import okhttp3.OkHttpClient;
26+
27+
public class ReactNativeFlipper {
28+
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29+
if (FlipperUtils.shouldEnableFlipper(context)) {
30+
final FlipperClient client = AndroidFlipperClient.getInstance(context);
31+
32+
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
33+
client.addPlugin(new ReactFlipperPlugin());
34+
client.addPlugin(new DatabasesFlipperPlugin(context));
35+
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
36+
client.addPlugin(CrashReporterPlugin.getInstance());
37+
38+
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
39+
NetworkingModule.setCustomClientBuilder(
40+
new NetworkingModule.CustomClientBuilder() {
41+
@Override
42+
public void apply(OkHttpClient.Builder builder) {
43+
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
44+
}
45+
});
46+
client.addPlugin(networkFlipperPlugin);
47+
client.start();
48+
49+
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
50+
// Hence we run if after all native modules have been initialized
51+
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
52+
if (reactContext == null) {
53+
reactInstanceManager.addReactInstanceEventListener(
54+
new ReactInstanceManager.ReactInstanceEventListener() {
55+
@Override
56+
public void onReactContextInitialized(ReactContext reactContext) {
57+
reactInstanceManager.removeReactInstanceEventListener(this);
58+
reactContext.runOnNativeModulesQueueThread(
59+
new Runnable() {
60+
@Override
61+
public void run() {
62+
client.addPlugin(new FrescoFlipperPlugin());
63+
}
64+
});
65+
}
66+
});
67+
} else {
68+
client.addPlugin(new FrescoFlipperPlugin());
69+
}
70+
}
71+
}
72+
}

android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<activity
1414
android:name=".MainActivity"
1515
android:label="@string/app_name"
16-
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
16+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
17+
android:launchMode="singleTask"
1718
android:windowSoftInputMode="adjustResize">
1819
<intent-filter>
1920
<action android:name="android.intent.action.MAIN" />

0 commit comments

Comments
 (0)