Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit 2772c6f

Browse files
authored
Upgrade react-native to 0.62.2 (#146)
* Upgrade react-native to 0.62.2 - Tested on ios. * Upgrade packages and fix jest configs
1 parent 3f0f3b4 commit 2772c6f

35 files changed

+3515
-2517
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ We used [react-native-localize](https://github.com/react-native-community/react-
220220
i18n.fallbacks = true;
221221
i18n.translations = { en, ko, ja };
222222

223-
export const getString = (param: string, mapObj?: object): string => {
223+
export const getString = (param: string, mapObj?: Record<string, unknown>): string => {
224224
if (mapObj) {
225-
i18n.t(param, mapObj);
225+
return i18n.t(param, mapObj);
226226
}
227227
return i18n.t(param);
228228
};
@@ -269,7 +269,7 @@ We used [react-native-localize](https://github.com/react-native-community/react-
269269
isRTL: false,
270270
});
271271

272-
const getNumberFormatSettings = (): object => ({
272+
const getNumberFormatSettings = (): Record<string, unknown> => ({
273273
decimalSeparator: '.',
274274
groupingSeparator: ',',
275275
});

STRINGS.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (Array.isArray(locales)) {
1313
i18n.fallbacks = true;
1414
i18n.translations = { en, ko };
1515

16-
export const getString = (param: string, mapObj?: object): string => {
16+
export const getString = (param: string, mapObj?: Record<string, unknown>): string => {
1717
if (mapObj) {
1818
return i18n.t(param, mapObj);
1919
}

__mocks__/react-native-localize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const findBestAvailableLanguage = (): Partial<Locale> => ({
1414
isRTL: false,
1515
});
1616

17-
const getNumberFormatSettings = (): object => ({
17+
const getNumberFormatSettings = (): Record<string, unknown> => ({
1818
decimalSeparator: '.',
1919
groupingSeparator: ',',
2020
});

android/app/build.gradle

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import com.android.build.OutputFile
1515
* // the name of the generated asset file containing your JS bundle
1616
* bundleAssetName: "index.android.bundle",
1717
*
18-
* // the entry file for bundle generation
18+
* // the entry file for bundle generation. If none specified and
19+
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
20+
* // default. Can be overridden with ENTRY_FILE environment variable.
1921
* entryFile: "index.android.js",
2022
*
2123
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
@@ -76,7 +78,6 @@ import com.android.build.OutputFile
7678
*/
7779

7880
project.ext.react = [
79-
entryFile: "index.js",
8081
enableHermes: false, // clean and rebuild if changing
8182
]
8283

@@ -162,6 +163,14 @@ android {
162163
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
163164
}
164165
}
166+
167+
packagingOptions {
168+
pickFirst "lib/armeabi-v7a/libc++_shared.so"
169+
pickFirst "lib/arm64-v8a/libc++_shared.so"
170+
pickFirst "lib/x86/libc++_shared.so"
171+
pickFirst "lib/x86_64/libc++_shared.so"
172+
}
173+
165174
// applicationVariants are e.g. debug, release
166175
applicationVariants.all { variant ->
167176
variant.outputs.each { output ->
@@ -180,8 +189,23 @@ android {
180189

181190
dependencies {
182191
implementation fileTree(dir: "libs", include: ["*.jar"])
192+
//noinspection GradleDynamicVersion
183193
implementation "com.facebook.react:react-native:+" // From node_modules
184194

195+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
196+
197+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
198+
exclude group:'com.facebook.fbjni'
199+
}
200+
201+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
202+
exclude group:'com.facebook.flipper'
203+
}
204+
205+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
206+
exclude group:'com.facebook.flipper'
207+
}
208+
185209
if (enableHermes) {
186210
def hermesPath = "../../node_modules/hermes-engine/android/";
187211
debugImplementation files(hermesPath + "hermes-debug.aar")
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.dooboo;
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" />

android/app/src/main/java/com/dooboo/MainApplication.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Context;
55
import com.facebook.react.PackageList;
66
import com.facebook.react.ReactApplication;
7+
import com.facebook.react.ReactInstanceManager;
78
import com.facebook.react.ReactNativeHost;
89
import com.facebook.react.ReactPackage;
910
import com.facebook.soloader.SoLoader;
@@ -43,23 +44,28 @@ public ReactNativeHost getReactNativeHost() {
4344
public void onCreate() {
4445
super.onCreate();
4546
SoLoader.init(this, /* native exopackage */ false);
46-
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
47+
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
4748
}
4849

4950
/**
50-
* Loads Flipper in React Native templates.
51+
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
52+
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
5153
*
5254
* @param context
55+
* @param reactInstanceManager
5356
*/
54-
private static void initializeFlipper(Context context) {
57+
private static void initializeFlipper(
58+
Context context, ReactInstanceManager reactInstanceManager) {
5559
if (BuildConfig.DEBUG) {
5660
try {
5761
/*
5862
We use reflection here to pick up the class that initializes Flipper,
5963
since Flipper library is not available in release mode
6064
*/
61-
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
62-
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
65+
Class<?> aClass = Class.forName("com.dooboo.ReactNativeFlipper");
66+
aClass
67+
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
68+
.invoke(null, context, reactInstanceManager);
6369
} catch (ClassNotFoundException e) {
6470
e.printStackTrace();
6571
} catch (NoSuchMethodException e) {

android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ buildscript {
66
minSdkVersion = 16
77
compileSdkVersion = 28
88
targetSdkVersion = 28
9-
supportLibVersion = "28.0.0"
109
}
1110
repositories {
1211
google()
1312
jcenter()
1413
}
1514
dependencies {
16-
classpath("com.android.tools.build:gradle:3.4.2")
15+
classpath("com.android.tools.build:gradle:3.5.2")
1716

1817
// NOTE: Do not place your application dependencies here; they belong
1918
// in the individual module build.gradle files

android/gradle.properties

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,12 @@
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1818
# org.gradle.parallel=true
1919

20-
# android.useAndroidX=true
21-
# android.enableJetifier=true
20+
# AndroidX package structure to make it clearer which packages are bundled with the
21+
# Android operating system, and which are packaged with your app's APK
22+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
23+
android.useAndroidX=true
24+
# Automatically convert third-party libraries to use AndroidX
25+
android.enableJetifier=true
26+
27+
# Version of flipper SDK to use with React Native
28+
FLIPPER_VERSION=0.33.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

android/gradlew

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# you may not use this file except in compliance with the License.
88
# You may obtain a copy of the License at
99
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
10+
# https://www.apache.org/licenses/LICENSE-2.0
1111
#
1212
# Unless required by applicable law or agreed to in writing, software
1313
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -125,8 +125,8 @@ if $darwin; then
125125
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126126
fi
127127

128-
# For Cygwin, switch paths to Windows format before running java
129-
if $cygwin ; then
128+
# For Cygwin or MSYS, switch paths to Windows format before running java
129+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130130
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131131
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132132
JAVACMD=`cygpath --unix "$JAVACMD"`

android/gradlew.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
@rem you may not use this file except in compliance with the License.
66
@rem You may obtain a copy of the License at
77
@rem
8-
@rem http://www.apache.org/licenses/LICENSE-2.0
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
99
@rem
1010
@rem Unless required by applicable law or agreed to in writing, software
1111
@rem distributed under the License is distributed on an "AS IS" BASIS,

babel.config.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,7 @@ module.exports = {
55
],
66
sourceMaps: 'inline',
77
plugins: [
8-
[
9-
'@babel/plugin-proposal-decorators',
10-
{
11-
legacy: true,
12-
},
13-
],
14-
[
15-
'@babel/plugin-transform-runtime',
16-
{
17-
helpers: true,
18-
regenerator: false,
19-
},
20-
],
8+
'@babel/proposal-class-properties',
219
'@babel/proposal-object-rest-spread',
2210
],
2311
};

ios/Podfile

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
platform :ios, '9.0'
22
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
33

4+
def add_flipper_pods!
5+
version = '~> 0.33.1'
6+
pod 'FlipperKit', version, :configuration => 'Debug'
7+
pod 'FlipperKit/FlipperKitLayoutPlugin', version, :configuration => 'Debug'
8+
pod 'FlipperKit/SKIOSNetworkPlugin', version, :configuration => 'Debug'
9+
pod 'FlipperKit/FlipperKitUserDefaultsPlugin', version, :configuration => 'Debug'
10+
pod 'FlipperKit/FlipperKitReactPlugin', version, :configuration => 'Debug'
11+
end
12+
13+
# Post Install processing for Flipper
14+
def flipper_post_install(installer)
15+
installer.pods_project.targets.each do |target|
16+
if target.name == 'YogaKit'
17+
target.build_configurations.each do |config|
18+
config.build_settings['SWIFT_VERSION'] = '4.1'
19+
end
20+
end
21+
end
22+
end
23+
424
target 'dooboo' do
525
# Pods for dooboo
626
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
@@ -26,21 +46,29 @@ target 'dooboo' do
2646
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
2747
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
2848
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
29-
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
49+
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
3050
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
31-
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
51+
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true
3252

3353
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
3454
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
3555
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
3656

37-
3857
target 'doobooTests' do
39-
inherit! :search_paths
58+
inherit! :complete
4059
# Pods for testing
4160
end
4261

4362
use_native_modules!
63+
64+
# Enables Flipper.
65+
#
66+
# Note that if you have use_frameworks! enabled, Flipper will not work and
67+
# you should disable these next few lines.
68+
add_flipper_pods!
69+
post_install do |installer|
70+
flipper_post_install(installer)
71+
end
4472
end
4573

4674
target 'dooboo-tvOS' do
@@ -50,5 +78,4 @@ target 'dooboo-tvOS' do
5078
inherit! :search_paths
5179
# Pods for testing
5280
end
53-
5481
end

0 commit comments

Comments
 (0)