Skip to content

Commit 4829316

Browse files
authored
chore: updated reanimated to v3 (#1324)
* chore: updated react native to 71 * chore: updated reanimated to v3 * fix: added a fix for web initialization
1 parent a996b4a commit 4829316

37 files changed

+2111
-2645
lines changed

example/app/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@
1818
"@react-navigation/stack": "^6.0.11",
1919
"faker": "^4.1.0",
2020
"nanoid": "^3.3.3",
21-
"react": "17.0.2",
22-
"react-native": "0.68.1",
23-
"react-native-gesture-handler": "~2.8.0",
21+
"react": "18.2.0",
22+
"react-native": "0.71.3",
23+
"react-native-gesture-handler": "~2.9.0",
2424
"react-native-maps": "^0.30.1",
2525
"react-native-pager-view": "^5.4.24",
26-
"react-native-reanimated": "~2.12.0",
26+
"react-native-reanimated": "~2.14.4",
2727
"react-native-redash": "^16.0.11",
2828
"react-native-safe-area-context": "4.2.4",
2929
"react-native-screens": "^3.15.0",
3030
"react-native-tab-view": "^3.1.1",
3131
"@babel/core": "^7.13.10",
3232
"@babel/runtime": "^7.13.10",
3333
"@types/faker": "^4.1.12",
34-
"@types/react": "^17.0.35",
35-
"@types/react-native": "^0.66.5",
34+
"@types/react": "18.0.24",
35+
"@types/react-native": "0.71.3",
3636
"metro-react-native-babel-preset": "^0.67.0",
37-
"typescript": "^4.2.4"
37+
"typescript": "4.9.4"
3838
}
3939
}

example/bare/android/app/build.gradle

+55-195
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,57 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "com.facebook.react"
23

34
import com.android.build.OutputFile
45
import org.apache.tools.ant.taskdefs.condition.Os
56

67
/**
7-
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
8-
* and bundleReleaseJsAndAssets).
9-
* These basically call `react-native bundle` with the correct arguments during the Android build
10-
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
11-
* bundle directly from the development server. Below you can see all the possible configurations
12-
* and their defaults. If you decide to add a configuration block, make sure to add it before the
13-
* `apply from: "../../node_modules/react-native/react.gradle"` line.
14-
*
15-
* project.ext.react = [
16-
* // the name of the generated asset file containing your JS bundle
17-
* bundleAssetName: "index.android.bundle",
18-
*
19-
* // the entry file for bundle generation
20-
* entryFile: "index.android.js",
21-
*
22-
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
23-
* bundleCommand: "ram-bundle",
24-
*
25-
* // whether to bundle JS and assets in debug mode
26-
* bundleInDebug: false,
27-
*
28-
* // whether to bundle JS and assets in release mode
29-
* bundleInRelease: true,
30-
*
31-
* // whether to bundle JS and assets in another build variant (if configured).
32-
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
33-
* // The configuration property can be in the following formats
34-
* // 'bundleIn${productFlavor}${buildType}'
35-
* // 'bundleIn${buildType}'
36-
* // bundleInFreeDebug: true,
37-
* // bundleInPaidRelease: true,
38-
* // bundleInBeta: true,
39-
*
40-
* // whether to disable dev mode in custom build variants (by default only disabled in release)
41-
* // for BottomSheetExample: to disable dev mode in the staging build type (if configured)
42-
* devDisabledInStaging: true,
43-
* // The configuration property can be in the following formats
44-
* // 'devDisabledIn${productFlavor}${buildType}'
45-
* // 'devDisabledIn${buildType}'
46-
*
47-
* // the root of your project, i.e. where "package.json" lives
48-
* root: "../../",
49-
*
50-
* // where to put the JS bundle asset in debug mode
51-
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
52-
*
53-
* // where to put the JS bundle asset in release mode
54-
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
55-
*
56-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
57-
* // require('./image.png')), in debug mode
58-
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
59-
*
60-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
61-
* // require('./image.png')), in release mode
62-
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
63-
*
64-
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
65-
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
66-
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
67-
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
68-
* // for BottomSheetExample, you might want to remove it from here.
69-
* inputExcludes: ["android/**", "ios/**"],
70-
*
71-
* // override which node gets called and with what additional arguments
72-
* nodeExecutableAndArgs: ["node"],
73-
*
74-
* // supply additional arguments to the packager
75-
* extraPackagerArgs: []
76-
* ]
8+
* This is the configuration block to customize your React Native Android app.
9+
* By default you don't need to apply any configuration, just uncomment the lines you need.
7710
*/
78-
79-
project.ext.react = [
80-
enableHermes: true,
81-
entryFile: "index.ts",
82-
]
83-
84-
apply from: "../../node_modules/react-native/react.gradle"
11+
react {
12+
/* Folders */
13+
// The root of your project, i.e. where "package.json" lives. Default is '..'
14+
// root = file("../")
15+
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
16+
// reactNativeDir = file("../node_modules/react-native")
17+
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
18+
// codegenDir = file("../node_modules/react-native-codegen")
19+
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
20+
// cliFile = file("../node_modules/react-native/cli.js")
21+
22+
/* Variants */
23+
// The list of variants to that are debuggable. For those we're going to
24+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
25+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
26+
// debuggableVariants = ["liteDebug", "prodDebug"]
27+
28+
/* Bundling */
29+
// A list containing the node command and its flags. Default is just 'node'.
30+
// nodeExecutableAndArgs = ["node"]
31+
//
32+
// The command to run when bundling. By default is 'bundle'
33+
// bundleCommand = "ram-bundle"
34+
//
35+
// The path to the CLI configuration file. Default is empty.
36+
// bundleConfig = file(../rn-cli.config.js)
37+
//
38+
// The name of the generated asset file containing your JS bundle
39+
// bundleAssetName = "MyApplication.android.bundle"
40+
//
41+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
42+
// entryFile = file("../js/MyApplication.android.js")
43+
//
44+
// A list of extra flags to pass to the 'bundle' commands.
45+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
46+
// extraPackagerArgs = []
47+
48+
/* Hermes Commands */
49+
// The hermes compiler command to run. By default it is 'hermesc'
50+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
51+
//
52+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
53+
// hermesFlags = ["-O", "-output-source-map"]
54+
}
8555

8656
/**
8757
* Set this to true to create two separate APKs instead of one:
@@ -111,15 +81,6 @@ def enableProguardInReleaseBuilds = false
11181
*/
11282
def jscFlavor = 'org.webkit:android-jsc:+'
11383

114-
/**
115-
* Whether to enable the Hermes VM.
116-
*
117-
* This should be set on project.ext.react and that value will be read here. If it is not set
118-
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
119-
* and the benefits of using Hermes will therefore be sharply reduced.
120-
*/
121-
def enableHermes = project.ext.react.get("enableHermes", false);
122-
12384
/**
12485
* Architectures to build native code for in debug.
12586
*/
@@ -137,68 +98,6 @@ android {
13798
targetSdkVersion rootProject.ext.targetSdkVersion
13899
versionCode 1
139100
versionName "1.0"
140-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
141-
if (isNewArchitectureEnabled()) {
142-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
143-
externalNativeBuild {
144-
ndkBuild {
145-
arguments "APP_PLATFORM=android-21",
146-
"APP_STL=c++_shared",
147-
"NDK_TOOLCHAIN_VERSION=clang",
148-
"GENERATED_SRC_DIR=$buildDir/generated/source",
149-
"PROJECT_BUILD_DIR=$buildDir",
150-
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
151-
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
152-
"NODE_MODULES_DIR=$rootDir/../node_modules"
153-
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
154-
cppFlags "-std=c++17"
155-
}
156-
}
157-
if (!enableSeparateBuildPerCPUArchitecture) {
158-
ndk {
159-
abiFilters (*reactNativeArchitectures())
160-
}
161-
}
162-
}
163-
}
164-
if (isNewArchitectureEnabled()) {
165-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
166-
externalNativeBuild {
167-
ndkBuild {
168-
path "$projectDir/src/main/jni/Android.mk"
169-
}
170-
}
171-
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
172-
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
173-
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
174-
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
175-
into("$buildDir/react-ndk/exported")
176-
}
177-
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
178-
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
179-
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
180-
into("$buildDir/react-ndk/exported")
181-
}
182-
afterEvaluate {
183-
// If you wish to add a custom TurboModule or component locally,
184-
// you should uncomment this line.
185-
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
186-
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
187-
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
188-
// Due to a bug inside AGP, we have to explicitly set a dependency
189-
// between configureNdkBuild* tasks and the preBuild tasks.
190-
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
191-
configureNdkBuildRelease.dependsOn(preReleaseBuild)
192-
configureNdkBuildDebug.dependsOn(preDebugBuild)
193-
reactNativeArchitectures().each { architecture ->
194-
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
195-
dependsOn("preDebugBuild")
196-
}
197-
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
198-
dependsOn("preReleaseBuild")
199-
}
200-
}
201-
}
202101
}
203102
splits {
204103
abi {
@@ -245,63 +144,24 @@ android {
245144
}
246145

247146
dependencies {
248-
implementation fileTree(dir: "libs", include: ["*.jar"])
147+
// The version of react-native is set by the React Native Gradle Plugin
148+
implementation("com.facebook.react:react-android")
149+
249150
//noinspection GradleDynamicVersion
250-
implementation "com.facebook.react:react-native:+" // From node_modules
251151
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
252152
implementation 'androidx.work:work-runtime-ktx:2.7.1'
253153

254-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
255-
exclude group:'com.facebook.fbjni'
256-
}
154+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
257155
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
258-
exclude group:'com.facebook.flipper'
259156
exclude group:'com.squareup.okhttp3', module:'okhttp'
260157
}
261-
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
262-
exclude group:'com.facebook.flipper'
263-
}
264158

265-
if (enableHermes) {
266-
//noinspection GradleDynamicVersion
267-
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
268-
exclude group:'com.facebook.fbjni'
269-
}
159+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
160+
if (hermesEnabled.toBoolean()) {
161+
implementation("com.facebook.react:hermes-android")
270162
} else {
271163
implementation jscFlavor
272164
}
273-
274165
}
275166

276-
if (isNewArchitectureEnabled()) {
277-
// If new architecture is enabled, we let you build RN from source
278-
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
279-
// This will be applied to all the imported transtitive dependency.
280-
configurations.all {
281-
resolutionStrategy.dependencySubstitution {
282-
substitute(module("com.facebook.react:react-native"))
283-
.using(project(":ReactAndroid"))
284-
.because("On New Architecture we're building React Native from source")
285-
substitute(module("com.facebook.react:hermes-engine"))
286-
.using(project(":ReactAndroid:hermes-engine"))
287-
.because("On New Architecture we're building Hermes from source")
288-
}
289-
}
290-
}
291-
292-
// Run this once to be able to run the application with BUCK
293-
// puts all compile dependencies into folder libs for BUCK to use
294-
task copyDownloadableDepsToLibs(type: Copy) {
295-
from configurations.implementation
296-
into 'libs'
297-
}
298-
299-
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
300-
301-
def isNewArchitectureEnabled() {
302-
// To opt-in for the New Architecture, you can either:
303-
// - Set `newArchEnabled` to true inside the `gradle.properties` file
304-
// - Invoke gradle with `-newArchEnabled=true`
305-
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
306-
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
307-
}
167+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

example/bare/android/app/src/debug/java/dev/gorhom/bottomsheet/ReactNativeFlipper.java

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
1818
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
1919
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20-
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
2120
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
2221
import com.facebook.react.ReactInstanceEventListener;
2322
import com.facebook.react.ReactInstanceManager;
@@ -30,7 +29,6 @@ public static void initializeFlipper(Context context, ReactInstanceManager react
3029
if (FlipperUtils.shouldEnableFlipper(context)) {
3130
final FlipperClient client = AndroidFlipperClient.getInstance(context);
3231
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
33-
client.addPlugin(new ReactFlipperPlugin());
3432
client.addPlugin(new DatabasesFlipperPlugin(context));
3533
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
3634
client.addPlugin(CrashReporterPlugin.getInstance());

example/bare/android/app/src/main/java/dev/gorhom/bottomsheet/MainActivity.java

+15-22
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.facebook.react.ReactActivity;
66
import com.facebook.react.ReactActivityDelegate;
77
import com.facebook.react.ReactRootView;
8+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
9+
import com.facebook.react.defaults.DefaultReactActivityDelegate;
810

911
public class MainActivity extends ReactActivity {
1012

@@ -22,29 +24,20 @@ protected String getMainComponentName() {
2224
return "BottomSheetExample";
2325
}
2426

27+
/**
28+
* Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
29+
* DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
30+
* (aka React 18) with two boolean flags.
31+
*/
2532
@Override
2633
protected ReactActivityDelegate createReactActivityDelegate() {
27-
return new MainActivityDelegate(this, getMainComponentName());
28-
}
29-
30-
public static class MainActivityDelegate extends ReactActivityDelegate {
31-
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
32-
super(activity, mainComponentName);
33-
}
34-
35-
@Override
36-
protected ReactRootView createRootView() {
37-
ReactRootView reactRootView = new ReactRootView(getContext());
38-
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
39-
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
40-
return reactRootView;
41-
}
42-
43-
@Override
44-
protected boolean isConcurrentRootEnabled() {
45-
// If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
46-
// More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
47-
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
48-
}
34+
return new DefaultReactActivityDelegate(
35+
this,
36+
getMainComponentName(),
37+
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
38+
DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
39+
// If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
40+
DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
41+
);
4942
}
5043
}

0 commit comments

Comments
 (0)