Skip to content

Commit a0eafe7

Browse files
authored
Upgrade react native version (#436)
* Upgrade react native version * update pod file * fix * fix * fix * fix ios * fix lint and spell * bump RN android minsdkversion * fix ndkversion and swift lint
1 parent a6a0704 commit a0eafe7

39 files changed

+5668
-4276
lines changed

binding/react-native/android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ android {
3535
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
3636
buildToolsVersion getExtOrDefault('buildToolsVersion')
3737
defaultConfig {
38-
minSdkVersion 21
38+
minSdkVersion 24
3939
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
4040
versionCode 1
4141
versionName "1.0"

binding/react-native/test-app/LeopardTestApp/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: true,
3-
extends: '@react-native-community',
3+
extends: '@react-native',
44
plugins: ['detox'],
55
overrides: [
66
{

binding/react-native/test-app/LeopardTestApp/.gitignore

+14-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
ios/.xcode.env.local
23+
**/.xcode.env.local
2424

2525
# Android/IntelliJ
2626
#
@@ -33,6 +33,7 @@ local.properties
3333
.cxx/
3434
*.keystore
3535
!debug.keystore
36+
.kotlin/
3637

3738
# node.js
3839
#
@@ -56,12 +57,23 @@ yarn-error.log
5657
*.jsbundle
5758

5859
# Ruby / CocoaPods
59-
/ios/Pods/
60+
**/Pods/
6061
/vendor/bundle/
6162

6263
# Temporary files created by Metro to check the health of the file watcher
6364
.metro-health-check*
6465

66+
# testing
67+
/coverage
68+
69+
# Yarn
70+
.yarn/*
71+
!.yarn/patches
72+
!.yarn/plugins
73+
!.yarn/releases
74+
!.yarn/sdks
75+
!.yarn/versions
76+
6577
test_data.json
6678
android/app/src/main/assets
6779
ios/LeopardTestApp/Assets.bundle

binding/react-native/test-app/LeopardTestApp/App.tsx

+15-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import React, {useState} from 'react';
1313
import {
14-
SafeAreaView,
1514
Button,
1615
ScrollView,
1716
StatusBar,
@@ -41,12 +40,24 @@ function printResults(results: Result[]) {
4140
});
4241
}
4342

44-
function App(): JSX.Element {
43+
function App(): React.JSX.Element {
4544
const isDarkMode = useColorScheme() === 'dark';
4645
const backgroundStyle = {
4746
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
47+
flex: 1,
4848
};
4949

50+
/*
51+
* To keep the template simple and small we're adding padding to prevent view
52+
* from rendering under the System UI.
53+
* For bigger apps the recommendation is to use `react-native-safe-area-context`:
54+
* https://github.com/AppAndFlow/react-native-safe-area-context
55+
*
56+
* You can read more about it here:
57+
* https://github.com/react-native-community/discussions-and-proposals/discussions/827
58+
*/
59+
const safePadding = '5%';
60+
5061
const [running, setRunning] = useState(false);
5162
const [results, setResults] = useState<Result[]>([]);
5263

@@ -58,7 +69,7 @@ function App(): JSX.Element {
5869
};
5970

6071
return (
61-
<SafeAreaView style={backgroundStyle}>
72+
<View style={backgroundStyle}>
6273
<StatusBar
6374
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
6475
backgroundColor={backgroundStyle.backgroundColor}
@@ -83,7 +94,7 @@ function App(): JSX.Element {
8394
)}
8495
</View>
8596
</ScrollView>
86-
</SafeAreaView>
97+
</View>
8798
);
8899
}
89100

binding/react-native/test-app/LeopardTestApp/__tests__/App-test.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
* @format
33
*/
44

5-
import 'react-native';
65
import React from 'react';
6+
import ReactTestRenderer from 'react-test-renderer';
77
import App from '../App';
88

9-
// Note: test renderer must be required after react-native.
10-
import renderer from 'react-test-renderer';
11-
12-
it('renders correctly', () => {
13-
renderer.create(<App />);
9+
test('renders correctly', async () => {
10+
await ReactTestRenderer.act(() => {
11+
ReactTestRenderer.create(<App />);
12+
});
1413
});

binding/react-native/test-app/LeopardTestApp/android/app/build.gradle

+16-55
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "org.jetbrains.kotlin.android"
23
apply plugin: "com.facebook.react"
34

4-
import com.android.build.OutputFile
5-
65
/**
76
* This is the configuration block to customize your React Native Android app.
87
* By default you don't need to apply any configuration, just uncomment the lines you need.
98
*/
109
react {
1110
/* Folders */
12-
// The root of your project, i.e. where "package.json" lives. Default is '..'
13-
// root = file("../")
14-
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
15-
// reactNativeDir = file("../node-modules/react-native")
16-
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
17-
// codegenDir = file("../node-modules/react-native-codegen")
18-
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
19-
// cliFile = file("../node_modules/react-native/cli.js")
11+
// The root of your project, i.e. where "package.json" lives. Default is '../..'
12+
// root = file("../../")
13+
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
14+
// reactNativeDir = file("../../node_modules/react-native")
15+
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
16+
// codegenDir = file("../../node_modules/@react-native/codegen")
17+
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
18+
// cliFile = file("../../node_modules/react-native/cli.js")
2019

2120
/* Variants */
2221
// The list of variants to that are debuggable. For those we're going to
@@ -50,15 +49,10 @@ react {
5049
//
5150
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
5251
// hermesFlags = ["-O", "-output-source-map"]
53-
}
5452

55-
/**
56-
* Set this to true to create four separate APKs instead of one,
57-
* one for each native architecture. This is useful if you don't
58-
* use App Bundles (https://developer.android.com/guide/app-bundle/)
59-
* and want to have separate APKs to upload to the Play Store.
60-
*/
61-
def enableSeparateBuildPerCPUArchitecture = false
53+
/* Autolinking */
54+
autolinkLibrariesWithApp()
55+
}
6256

6357
/**
6458
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
@@ -69,14 +63,14 @@ def enableProguardInReleaseBuilds = false
6963
* The preferred build flavor of JavaScriptCore (JSC)
7064
*
7165
* For example, to use the international variant, you can use:
72-
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
66+
* `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
7367
*
7468
* The international variant includes ICU i18n library and necessary data
7569
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
7670
* give correct results when using with locales other than en-US. Note that
7771
* this variant is about 6MiB larger per architecture than default.
7872
*/
79-
def jscFlavor = 'org.webkit:android-jsc:+'
73+
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
8074

8175
/**
8276
* Private function to get the list of Native Architectures you want to build.
@@ -91,7 +85,8 @@ def reactNativeArchitectures() {
9185
android {
9286
ndkVersion rootProject.ext.ndkVersion
9387

94-
compileSdkVersion rootProject.ext.compileSdkVersion
88+
buildToolsVersion rootProject.ext.buildToolsVersion
89+
compileSdk rootProject.ext.compileSdkVersion
9590

9691
namespace "com.leopardtestapp"
9792
defaultConfig {
@@ -105,14 +100,6 @@ android {
105100
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
106101
}
107102

108-
splits {
109-
abi {
110-
reset()
111-
enable enableSeparateBuildPerCPUArchitecture
112-
universalApk false // If true, also generate a universal APK
113-
include (*reactNativeArchitectures())
114-
}
115-
}
116103
signingConfigs {
117104
debug {
118105
storeFile file('debug.keystore')
@@ -134,36 +121,12 @@ android {
134121
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
135122
}
136123
}
137-
138-
// applicationVariants are e.g. debug, release
139-
applicationVariants.all { variant ->
140-
variant.outputs.each { output ->
141-
// For each separate APK per architecture, set a unique version code as described here:
142-
// https://developer.android.com/studio/build/configure-apk-splits.html
143-
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
144-
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
145-
def abi = output.getFilter(OutputFile.ABI)
146-
if (abi != null) { // null for the universal-debug, universal-release variants
147-
output.versionCodeOverride =
148-
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
149-
}
150-
151-
}
152-
}
153124
}
154125

155126
dependencies {
156127
// The version of react-native is set by the React Native Gradle Plugin
157128
implementation("com.facebook.react:react-android")
158129

159-
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
160-
161-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
162-
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
163-
exclude group:'com.squareup.okhttp3', module:'okhttp'
164-
}
165-
166-
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
167130
if (hermesEnabled.toBoolean()) {
168131
implementation("com.facebook.react:hermes-android")
169132
} else {
@@ -173,5 +136,3 @@ dependencies {
173136
androidTestImplementation('com.wix:detox:+')
174137
implementation 'androidx.appcompat:appcompat:1.1.0'
175138
}
176-
177-
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

binding/react-native/test-app/LeopardTestApp/android/app/src/debug/AndroidManifest.xml

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
<application
88
android:usesCleartextTraffic="true"
99
tools:targetApi="28"
10-
tools:ignore="GoogleAppIndexingWarning">
11-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
12-
</application>
10+
tools:ignore="GoogleAppIndexingWarning"/>
1311
</manifest>

binding/react-native/test-app/LeopardTestApp/android/app/src/main/AndroidManifest.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:allowBackup="false"
1111
android:theme="@style/AppTheme"
12-
android:networkSecurityConfig="@xml/network_security_config">
12+
android:networkSecurityConfig="@xml/network_security_config"
13+
android:supportsRtl="true">
1314
<activity
1415
android:name=".MainActivity"
1516
android:label="@string/app_name"

binding/react-native/test-app/LeopardTestApp/android/app/src/main/java/com/leopardtestapp/MainActivity.java

-35
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.leopardtestapp
2+
3+
import com.facebook.react.ReactActivity
4+
import com.facebook.react.ReactActivityDelegate
5+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
6+
import com.facebook.react.defaults.DefaultReactActivityDelegate
7+
8+
class MainActivity : ReactActivity() {
9+
10+
/**
11+
* Returns the name of the main component registered from JavaScript. This is used to schedule
12+
* rendering of the component.
13+
*/
14+
override fun getMainComponentName(): String = "LeopardTestApp"
15+
16+
/**
17+
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
18+
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
19+
*/
20+
override fun createReactActivityDelegate(): ReactActivityDelegate =
21+
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
22+
}

0 commit comments

Comments
 (0)