Skip to content

Commit a9c9fd9

Browse files
authored
Add support for React Native 0.72 (software-mansion#4253)
## Summary This PR adds support for React Native 0.72.0 as well as bumps React Native version in Example and FabricExample to 0.72.0-rc.1. See https://react-native-community.github.io/upgrade-helper/?from=0.71.3&to=0.72.0-rc.1 for changes. ### TODO - [x] bump version in project root - [x] bump version in Example - [x] bump version in FabricExample - [x] update metro-inspector-proxy patch - [x] change Node version on CI - [x] ~~add `react-native/ReactCommon/react/renderer/components/` to .gitignore?~~ fixed in RN - [x] check if `FBReactNativeSpec` is still required on older versions of RN - [x] fix ESLint errors in Example app - [x] ~~remove `-DRN_FABRIC_ENABLED` from xcproject~~ it's ok ### Checklist - [x] check all configurations (Example/FabricExample, Android/iOS) - iOS / Paper / debug ✅ - iOS / Paper / release ✅ - Android / Paper / debug ✅ - Andorid / Paper / release ✅ - iOS / Fabric / debug ✅ - iOS / Fabric / release ✅ - Android / Fabric / debug ✅ - Android / Fabric / release ✅ - [x] check debugging worklet runtime via Chrome DevTools - [x] check debugging in Android Studio - [x] check production builds ## Test plan
1 parent d6c2711 commit a9c9fd9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3623
-4455
lines changed

.github/workflows/build-v8.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
- main
1616

1717
env:
18-
REACT_NATIVE_VERSION: "0.71.3"
18+
REACT_NATIVE_VERSION: "0.71.6"
1919

2020
jobs:
2121
build:

Common/cpp/Fabric/FabricUtils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct UIManagerPublic {
3636
struct BindingPublic : public jni::HybridClass<Binding>,
3737
public SchedulerDelegate,
3838
public LayoutAnimationStatusDelegate {
39-
butter::shared_mutex installMutex_;
39+
std::shared_mutex installMutex_;
4040
std::shared_ptr<FabricMountingManager> mountingManager_;
4141
std::shared_ptr<facebook::react::Scheduler> scheduler_;
4242
};

Common/cpp/NativeModules/NativeReanimatedModule.cpp

+28-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "NativeReanimatedModule.h"
22

33
#ifdef RCT_NEW_ARCH_ENABLED
4+
#include <react/renderer/core/TraitCast.h>
45
#include <react/renderer/uimanager/UIManagerBinding.h>
56
#include <react/renderer/uimanager/primitives.h>
67
#endif
@@ -554,37 +555,40 @@ void NativeReanimatedModule::performOperations() {
554555
shadowTreeRegistry.visit(surfaceId_, [&](ShadowTree const &shadowTree) {
555556
auto lock = newestShadowNodesRegistry_->createLock();
556557

557-
shadowTree.commit([&](RootShadowNode const &oldRootShadowNode) {
558-
auto rootNode = oldRootShadowNode.ShadowNode::clone(ShadowNodeFragment{});
558+
shadowTree.commit(
559+
[&](RootShadowNode const &oldRootShadowNode) {
560+
auto rootNode =
561+
oldRootShadowNode.ShadowNode::clone(ShadowNodeFragment{});
559562

560-
ShadowTreeCloner shadowTreeCloner{
561-
newestShadowNodesRegistry_, uiManager_, surfaceId_};
563+
ShadowTreeCloner shadowTreeCloner{
564+
newestShadowNodesRegistry_, uiManager_, surfaceId_};
562565

563-
for (const auto &pair : copiedOperationsQueue) {
564-
const ShadowNodeFamily &family = pair.first->getFamily();
565-
react_native_assert(family.getSurfaceId() == surfaceId_);
566+
for (const auto &pair : copiedOperationsQueue) {
567+
const ShadowNodeFamily &family = pair.first->getFamily();
568+
react_native_assert(family.getSurfaceId() == surfaceId_);
566569

567-
auto newRootNode = shadowTreeCloner.cloneWithNewProps(
568-
rootNode, family, RawProps(rt, *pair.second));
570+
auto newRootNode = shadowTreeCloner.cloneWithNewProps(
571+
rootNode, family, RawProps(rt, *pair.second));
569572

570-
if (newRootNode == nullptr) {
571-
// this happens when React removed the component but Reanimated
572-
// still tries to animate it, let's skip update for this specific
573-
// component
574-
continue;
575-
}
576-
rootNode = newRootNode;
577-
}
573+
if (newRootNode == nullptr) {
574+
// this happens when React removed the component but Reanimated
575+
// still tries to animate it, let's skip update for this specific
576+
// component
577+
continue;
578+
}
579+
rootNode = newRootNode;
580+
}
578581

579-
// remove ShadowNodes and its ancestors from NewestShadowNodesRegistry
580-
for (auto tag : copiedTagsToRemove) {
581-
newestShadowNodesRegistry_->remove(tag);
582-
}
582+
// remove ShadowNodes and its ancestors from NewestShadowNodesRegistry
583+
for (auto tag : copiedTagsToRemove) {
584+
newestShadowNodesRegistry_->remove(tag);
585+
}
583586

584-
shadowTreeCloner.updateYogaChildren();
587+
shadowTreeCloner.updateYogaChildren();
585588

586-
return std::static_pointer_cast<RootShadowNode>(rootNode);
587-
});
589+
return std::static_pointer_cast<RootShadowNode>(rootNode);
590+
},
591+
{/* default commit options */});
588592
});
589593
}
590594

Example/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
22
root: true,
3-
extends: '@react-native-community',
3+
extends: '@react-native',
44
};

Example/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ yarn-error.log
6161

6262
# Temporary files created by Metro to check the health of the file watcher
6363
.metro-health-check*
64+
65+
# testing
66+
/coverage

Example/.node-version

-1
This file was deleted.

Example/.ruby-version

-1
This file was deleted.

Example/.watchmanconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}

Example/Gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source 'https://rubygems.org'
22

33
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4-
ruby File.read(File.join(__dir__, '.ruby-version')).strip
4+
ruby ">= 2.6.10"
55

6-
gem 'cocoapods', '~> 1.11', '>= 1.11.3'
6+
gem 'cocoapods', '~> 1.12'

Example/android/app/src/main/java/com/swmansion/reanimated/example/MainActivity.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ protected ReactActivityDelegate createReactActivityDelegate() {
2727
this,
2828
getMainComponentName(),
2929
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
30-
DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
31-
// If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
32-
DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
33-
);
30+
DefaultNewArchitectureEntryPoint.getFabricEnabled());
3431
}
3532
}

Example/android/app/src/main/res/drawable/rn_edit_text_material.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
android:insetBottom="@dimen/abc_edit_text_inset_bottom_material">
2121

2222
<selector>
23-
<!--
23+
<!--
2424
This file is a copy of abc_edit_text_material (https://bit.ly/3k8fX7I).
2525
The item below with state_pressed="false" and state_focused="false" causes a NullPointerException.
2626
NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)'

Example/android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ buildscript {
1616
mavenCentral()
1717
}
1818
dependencies {
19-
classpath("com.android.tools.build:gradle:7.3.1")
19+
classpath("com.android.tools.build:gradle")
2020
classpath("com.facebook.react:react-native-gradle-plugin")
2121
}
2222
}

Example/android/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ android.useAndroidX=true
2525
android.enableJetifier=true
2626

2727
# Version of flipper SDK to use with React Native
28-
FLIPPER_VERSION=0.125.0
28+
FLIPPER_VERSION=0.182.0
2929

3030
# Use this property to specify which architecture you want to build.
3131
# You can also override it from the CLI using
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
4+
networkTimeout=10000
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

Example/android/gradlew

+14-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,10 +80,10 @@ do
8080
esac
8181
done
8282

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
83+
# This is normally unused
84+
# shellcheck disable=SC2034
8685
APP_BASE_NAME=${0##*/}
86+
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
8787

8888
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
8989
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
@@ -143,12 +143,16 @@ fi
143143
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144144
case $MAX_FD in #(
145145
max*)
146+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147+
# shellcheck disable=SC3045
146148
MAX_FD=$( ulimit -H -n ) ||
147149
warn "Could not query maximum file descriptor limit"
148150
esac
149151
case $MAX_FD in #(
150152
'' | soft) :;; #(
151153
*)
154+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155+
# shellcheck disable=SC3045
152156
ulimit -n "$MAX_FD" ||
153157
warn "Could not set maximum file descriptor limit to $MAX_FD"
154158
esac
@@ -205,6 +209,12 @@ set -- \
205209
org.gradle.wrapper.GradleWrapperMain \
206210
"$@"
207211

212+
# Stop when "xargs" is not available.
213+
if ! command -v xargs >/dev/null 2>&1
214+
then
215+
die "xargs is not available"
216+
fi
217+
208218
# Use "xargs" to parse quoted args.
209219
#
210220
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

Example/android/gradlew.bat

+9-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@rem limitations under the License.
1515
@rem
1616

17-
@if "%DEBUG%" == "" @echo off
17+
@if "%DEBUG%"=="" @echo off
1818
@rem ##########################################################################
1919
@rem
2020
@rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
2525
if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
28+
if "%DIRNAME%"=="" set DIRNAME=.
29+
@rem This is normally unused
2930
set APP_BASE_NAME=%~n0
3031
set APP_HOME=%DIRNAME%
3132

@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4041

4142
set JAVA_EXE=java.exe
4243
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
44+
if %ERRORLEVEL% equ 0 goto execute
4445

4546
echo.
4647
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7576

7677
:end
7778
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
79+
if %ERRORLEVEL% equ 0 goto mainEnd
7980

8081
:fail
8182
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8283
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
84+
set EXIT_CODE=%ERRORLEVEL%
85+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
86+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87+
exit /b %EXIT_CODE%
8588

8689
:mainEnd
8790
if "%OS%"=="Windows_NT" endlocal

Example/android/settings.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
rootProject.name = 'ReanimatedExample'
22
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
33
include ':app'
4-
includeBuild('../node_modules/react-native-gradle-plugin')
4+
includeBuild('../node_modules/@react-native/gradle-plugin')

Example/ios/Podfile

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
require_relative '../node_modules/react-native/scripts/react_native_pods'
2-
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
1+
# Resolve react_native_pods.rb with node to allow for hoisting
2+
require Pod::Executable.execute_command('node', ['-p',
3+
'require.resolve(
4+
"react-native/scripts/react_native_pods.rb",
5+
{paths: [process.argv[1]]},
6+
)', __dir__]).strip
37

48
ENV['REANIMATED_EXAMPLE_APP_NAME'] = 'Example'
59

@@ -32,8 +36,6 @@ target 'ReanimatedExample' do
3236
use_react_native!(
3337
:path => config[:reactNativePath],
3438
# Hermes is now enabled by default. Disable by setting this flag to false.
35-
# Upcoming versions of React Native may rely on get_default_flags(), but
36-
# we make it explicit here to aid in the React Native upgrade process.
3739
:hermes_enabled => flags[:hermes_enabled],
3840
:fabric_enabled => flags[:fabric_enabled],
3941
# Enables Flipper.
@@ -51,10 +53,10 @@ target 'ReanimatedExample' do
5153
end
5254

5355
post_install do |installer|
56+
# https://github.com/facebook/react-native/blob/main/scripts/react_native_pods.rb#L197-L202
5457
react_native_post_install(
5558
installer,
56-
# Set `mac_catalyst_enabled` to `true` in order to apply patches
57-
# necessary for Mac Catalyst builds
59+
config[:reactNativePath],
5860
:mac_catalyst_enabled => false
5961
)
6062
__apply_Xcode_12_5_M1_post_install_workaround(installer)

0 commit comments

Comments
 (0)