From 9f38719b5ee918d04fb16ac382c79f176587b49c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreiro?= Date: Tue, 6 Dec 2022 16:52:44 +0000 Subject: [PATCH] update RN to 0.70 (untested) --- .gitignore | 9 ++- .node-version | 1 + .ruby-version | 2 +- Gemfile | 2 +- android/app/build.gradle | 55 ++++++++----------- .../xyz/blueskyweb/pubsq/MainActivity.java | 10 +++- .../MainApplicationReactNativeHost.java | 2 +- android/app/src/main/jni/Android.mk | 49 ----------------- android/app/src/main/jni/CMakeLists.txt | 5 ++ .../jni/MainApplicationModuleProvider.cpp | 9 ++- .../main/jni/MainApplicationModuleProvider.h | 2 +- ...nApplicationTurboModuleManagerDelegate.cpp | 8 +-- ...ainApplicationTurboModuleManagerDelegate.h | 8 +-- .../src/main/jni/MainComponentsRegistry.cpp | 4 ++ android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- android/settings.gradle | 2 + ios/.xcode.env | 11 ++++ ios/Podfile | 21 ++++--- ios/app.xcodeproj/project.pbxproj | 10 ++-- ios/app/AppDelegate.mm | 24 +++++++- package.json | 8 +-- 22 files changed, 128 insertions(+), 118 deletions(-) create mode 100644 .node-version delete mode 100644 android/app/src/main/jni/Android.mk create mode 100644 android/app/src/main/jni/CMakeLists.txt create mode 100644 ios/.xcode.env diff --git a/.gitignore b/.gitignore index 81570d9918..2423126f72 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ DerivedData *.hmap *.ipa *.xcuserstate +ios/.xcode.env.local # Android/IntelliJ # @@ -29,6 +30,7 @@ build/ local.properties *.iml *.hprof +.cxx/ # node.js # @@ -49,9 +51,10 @@ buck-out/ # For more information about the recommended setup visit: # https://docs.fastlane.tools/best-practices/source-control/ -*/fastlane/report.xml -*/fastlane/Preview.html -*/fastlane/screenshots +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output # Bundle artifact *.jsbundle diff --git a/.node-version b/.node-version new file mode 100644 index 0000000000..19c7bdba7b --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +16 \ No newline at end of file diff --git a/.ruby-version b/.ruby-version index a4dd9dba4f..a603bb50a2 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.4 +2.7.5 diff --git a/Gemfile b/Gemfile index 2c3edcf4b7..5efda89f45 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version -ruby '2.7.4' +ruby '2.7.5' gem 'cocoapods', '~> 1.11', '>= 1.11.2' diff --git a/android/app/build.gradle b/android/app/build.gradle index 932c12d13e..466134f4f8 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -79,7 +79,7 @@ import org.apache.tools.ant.taskdefs.condition.Os */ project.ext.react = [ - enableHermes: false, // clean and rebuild if changing + enableHermes: true, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" @@ -143,26 +143,14 @@ android { buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() if (isNewArchitectureEnabled()) { - // We configure the NDK build only if you decide to opt-in for the New Architecture. + // We configure the CMake build only if you decide to opt-in for the New Architecture. externalNativeBuild { - ndkBuild { - arguments "APP_PLATFORM=android-21", - "APP_STL=c++_shared", - "NDK_TOOLCHAIN_VERSION=clang", - "GENERATED_SRC_DIR=$buildDir/generated/source", - "PROJECT_BUILD_DIR=$buildDir", - "REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid", - "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build" - cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1" - cppFlags "-std=c++17" - // Make sure this target name is the same you specify inside the - // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable. - targets "app_appmodules" - - // Fix for windows limit on number of character in file paths and in command lines - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - arguments "NDK_APP_SHORT_COMMANDS=true" - } + cmake { + arguments "-DPROJECT_BUILD_DIR=$buildDir", + "-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid", + "-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build", + "-DNODE_MODULES_DIR=$rootDir/../node_modules", + "-DANDROID_STL=c++_shared" } } if (!enableSeparateBuildPerCPUArchitecture) { @@ -176,8 +164,8 @@ android { if (isNewArchitectureEnabled()) { // We configure the NDK build only if you decide to opt-in for the New Architecture. externalNativeBuild { - ndkBuild { - path "$projectDir/src/main/jni/Android.mk" + cmake { + path "$projectDir/src/main/jni/CMakeLists.txt" } } def reactAndroidProjectDir = project(':ReactAndroid').projectDir @@ -199,15 +187,15 @@ android { preReleaseBuild.dependsOn(packageReactNdkReleaseLibs) // Due to a bug inside AGP, we have to explicitly set a dependency - // between configureNdkBuild* tasks and the preBuild tasks. + // between configureCMakeDebug* tasks and the preBuild tasks. // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732 - configureNdkBuildRelease.dependsOn(preReleaseBuild) - configureNdkBuildDebug.dependsOn(preDebugBuild) + configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild) + configureCMakeDebug.dependsOn(preDebugBuild) reactNativeArchitectures().each { architecture -> - tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure { + tasks.findByName("configureCMakeDebug[${architecture}]")?.configure { dependsOn("preDebugBuild") } - tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure { + tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure { dependsOn("preReleaseBuild") } } @@ -282,9 +270,10 @@ dependencies { } if (enableHermes) { - def hermesPath = "../../node_modules/hermes-engine/android/"; - debugImplementation files(hermesPath + "hermes-debug.aar") - releaseImplementation files(hermesPath + "hermes-release.aar") + //noinspection GradleDynamicVersion + implementation("com.facebook.react:hermes-engine:+") { // From node_modules + exclude group:'com.facebook.fbjni' + } } else { implementation jscFlavor } @@ -297,7 +286,11 @@ if (isNewArchitectureEnabled()) { configurations.all { resolutionStrategy.dependencySubstitution { substitute(module("com.facebook.react:react-native")) - .using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source") + .using(project(":ReactAndroid")) + .because("On New Architecture we're building React Native from source") + substitute(module("com.facebook.react:hermes-engine")) + .using(project(":ReactAndroid:hermes-engine")) + .because("On New Architecture we're building Hermes from source") } } } diff --git a/android/app/src/main/java/xyz/blueskyweb/pubsq/MainActivity.java b/android/app/src/main/java/xyz/blueskyweb/pubsq/MainActivity.java index c8c347ad51..92d78d6557 100644 --- a/android/app/src/main/java/xyz/blueskyweb/pubsq/MainActivity.java +++ b/android/app/src/main/java/xyz/blueskyweb/pubsq/MainActivity.java @@ -18,7 +18,8 @@ public class MainActivity extends ReactActivity { /** * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and - * you can specify the rendered you wish to use (Fabric or the older renderer). + * you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer + * (Paper). */ @Override protected ReactActivityDelegate createReactActivityDelegate() { @@ -38,6 +39,13 @@ public class MainActivity extends ReactActivity { return reactRootView; } + @Override + protected boolean isConcurrentRootEnabled() { + // If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18). + // More on this on https://reactjs.org/blog/2022/03/29/react-v18.html + return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(null); diff --git a/android/app/src/main/java/xyz/blueskyweb/pubsq/newarchitecture/MainApplicationReactNativeHost.java b/android/app/src/main/java/xyz/blueskyweb/pubsq/newarchitecture/MainApplicationReactNativeHost.java index bb512caefd..d3786de8be 100644 --- a/android/app/src/main/java/xyz/blueskyweb/pubsq/newarchitecture/MainApplicationReactNativeHost.java +++ b/android/app/src/main/java/xyz/blueskyweb/pubsq/newarchitecture/MainApplicationReactNativeHost.java @@ -105,7 +105,7 @@ public class MainApplicationReactNativeHost extends ReactNativeHost { return new FabricJSIModuleProvider( reactApplicationContext, componentFactory, - new EmptyReactNativeConfig(), + ReactNativeConfig.DEFAULT_CONFIG, viewManagerRegistry); } }); diff --git a/android/app/src/main/jni/Android.mk b/android/app/src/main/jni/Android.mk deleted file mode 100644 index b3099f1224..0000000000 --- a/android/app/src/main/jni/Android.mk +++ /dev/null @@ -1,49 +0,0 @@ -THIS_DIR := $(call my-dir) - -include $(REACT_ANDROID_DIR)/Android-prebuilt.mk - -# If you wish to add a custom TurboModule or Fabric component in your app you -# will have to include the following autogenerated makefile. -# include $(GENERATED_SRC_DIR)/codegen/jni/Android.mk -include $(CLEAR_VARS) - -LOCAL_PATH := $(THIS_DIR) - -# You can customize the name of your application .so file here. -LOCAL_MODULE := app_appmodules - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -# If you wish to add a custom TurboModule or Fabric component in your app you -# will have to uncomment those lines to include the generated source -# files from the codegen (placed in $(GENERATED_SRC_DIR)/codegen/jni) -# -# LOCAL_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni -# LOCAL_SRC_FILES += $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp) -# LOCAL_EXPORT_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni - -# Here you should add any native library you wish to depend on. -LOCAL_SHARED_LIBRARIES := \ - libfabricjni \ - libfbjni \ - libfolly_futures \ - libfolly_json \ - libglog \ - libjsi \ - libreact_codegen_rncore \ - libreact_debug \ - libreact_nativemodule_core \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - librrc_view \ - libruntimeexecutor \ - libturbomodulejsijni \ - libyoga - -LOCAL_CFLAGS := -DLOG_TAG=\"ReactNative\" -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) diff --git a/android/app/src/main/jni/CMakeLists.txt b/android/app/src/main/jni/CMakeLists.txt new file mode 100644 index 0000000000..e5be16f05f --- /dev/null +++ b/android/app/src/main/jni/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.13) +# Define the library name here. +project(rndiffapp_appmodules) +# This file includes all the necessary to let you build your application with the New Architecture. +include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake) \ No newline at end of file diff --git a/android/app/src/main/jni/MainApplicationModuleProvider.cpp b/android/app/src/main/jni/MainApplicationModuleProvider.cpp index 0ac23cc626..5206765b58 100644 --- a/android/app/src/main/jni/MainApplicationModuleProvider.cpp +++ b/android/app/src/main/jni/MainApplicationModuleProvider.cpp @@ -6,7 +6,7 @@ namespace facebook { namespace react { std::shared_ptr MainApplicationModuleProvider( - const std::string moduleName, + const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { // Here you can provide your own module provider for TurboModules coming from // either your application or from external libraries. The approach to follow @@ -17,6 +17,13 @@ std::shared_ptr MainApplicationModuleProvider( // return module; // } // return rncore_ModuleProvider(moduleName, params); + + // Module providers autolinked by RN CLI + auto rncli_module = rncli_ModuleProvider(moduleName, params); + if (rncli_module != nullptr) { + return rncli_module; + } + return rncore_ModuleProvider(moduleName, params); } diff --git a/android/app/src/main/jni/MainApplicationModuleProvider.h b/android/app/src/main/jni/MainApplicationModuleProvider.h index 0fa43fa69a..b38ccf53fd 100644 --- a/android/app/src/main/jni/MainApplicationModuleProvider.h +++ b/android/app/src/main/jni/MainApplicationModuleProvider.h @@ -9,7 +9,7 @@ namespace facebook { namespace react { std::shared_ptr MainApplicationModuleProvider( - const std::string moduleName, + const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); } // namespace react diff --git a/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp b/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp index dbbdc3d132..5fd688c509 100644 --- a/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp +++ b/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp @@ -22,21 +22,21 @@ void MainApplicationTurboModuleManagerDelegate::registerNatives() { std::shared_ptr MainApplicationTurboModuleManagerDelegate::getTurboModule( - const std::string name, - const std::shared_ptr jsInvoker) { + const std::string &name, + const std::shared_ptr &jsInvoker) { // Not implemented yet: provide pure-C++ NativeModules here. return nullptr; } std::shared_ptr MainApplicationTurboModuleManagerDelegate::getTurboModule( - const std::string name, + const std::string &name, const JavaTurboModule::InitParams ¶ms) { return MainApplicationModuleProvider(name, params); } bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule( - std::string name) { + const std::string &name) { return getTurboModule(name, nullptr) != nullptr || getTurboModule(name, {.moduleName = name}) != nullptr; } diff --git a/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h b/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h index f9b1e8ae70..032553b19d 100644 --- a/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h +++ b/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h @@ -21,17 +21,17 @@ class MainApplicationTurboModuleManagerDelegate static void registerNatives(); std::shared_ptr getTurboModule( - const std::string name, - const std::shared_ptr jsInvoker) override; + const std::string &name, + const std::shared_ptr &jsInvoker) override; std::shared_ptr getTurboModule( - const std::string name, + const std::string &name, const JavaTurboModule::InitParams ¶ms) override; /** * Test-only method. Allows user to verify whether a TurboModule can be * created by instances of this class. */ - bool canCreateTurboModule(std::string name); + bool canCreateTurboModule(const std::string &name,); }; } // namespace react diff --git a/android/app/src/main/jni/MainComponentsRegistry.cpp b/android/app/src/main/jni/MainComponentsRegistry.cpp index 8f7edffd64..54f598a486 100644 --- a/android/app/src/main/jni/MainComponentsRegistry.cpp +++ b/android/app/src/main/jni/MainComponentsRegistry.cpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace facebook { namespace react { @@ -14,6 +15,9 @@ std::shared_ptr MainComponentsRegistry::sharedProviderRegistry() { auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry(); + // Autolinked providers registered by RN CLI + rncli_registerProviders(providerRegistry); + // Custom Fabric Components go here. You can register custom // components coming from your App or from 3rd party libraries here. // diff --git a/android/build.gradle b/android/build.gradle index e997cb0e66..692ab87d86 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -24,7 +24,7 @@ buildscript { dependencies { classpath('com.android.tools.build:gradle:7.2.1') classpath("com.facebook.react:react-native-gradle-plugin") - classpath("de.undercouch:gradle-download-task:4.1.2") + classpath("de.undercouch:gradle-download-task:5.0.1") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 669386b870..8fad3f5a98 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/android/settings.gradle b/android/settings.gradle index 3c22b7a2c7..f84b340371 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -6,4 +6,6 @@ includeBuild('../node_modules/react-native-gradle-plugin') if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { include(":ReactAndroid") project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid') + include(":ReactAndroid:hermes-engine") + project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine') } diff --git a/ios/.xcode.env b/ios/.xcode.env new file mode 100644 index 0000000000..bef731e8ea --- /dev/null +++ b/ios/.xcode.env @@ -0,0 +1,11 @@ + +# This `.xcode.env` file is versioned and is used to source the environment +# used when running script phases inside Xcode. +# To customize your local environment, you can create an `.xcode.env.local` +# file that is not versioned. +# NODE_BINARY variable contains the PATH to the node executable. +# +# Customize the NODE_BINARY variable here. +# For example, to use nvm with brew, add the following line +# . "$(brew --prefix nvm)/nvm.sh" --no-use +export NODE_BINARY=$(command -v node) \ No newline at end of file diff --git a/ios/Podfile b/ios/Podfile index f9a45704c4..ea4be3b939 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -13,9 +13,13 @@ target 'app' do use_react_native!( :path => config[:reactNativePath], - # to enable hermes on iOS, change `false` to `true` and then install pods - :hermes_enabled => flags[:hermes_enabled], + # Hermes is now enabled by default. Disable by setting this flag to false. + # Upcoming versions of React Native may rely on get_default_flags(), but + # we make it explicit here to aid in the React Native upgrade process. + :hermes_enabled => true, :fabric_enabled => flags[:fabric_enabled], + + :flipper_configuration => FlipperConfiguration.enabled, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) @@ -25,14 +29,13 @@ target 'app' do # Pods for testing end - # Enables Flipper. - # - # Note that if you have use_frameworks! enabled, Flipper will not work and - # you should disable the next line. - #use_flipper!() - post_install do |installer| - react_native_post_install(installer) + react_native_post_install( + installer, + # Set `mac_catalyst_enabled` to `true` in order to apply patches + # necessary for Mac Catalyst builds + :mac_catalyst_enabled => false + ) __apply_Xcode_12_5_M1_post_install_workaround(installer) # iOS fix diff --git a/ios/app.xcodeproj/project.pbxproj b/ios/app.xcodeproj/project.pbxproj index 50db4563af..7d23faf6f6 100644 --- a/ios/app.xcodeproj/project.pbxproj +++ b/ios/app.xcodeproj/project.pbxproj @@ -264,7 +264,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -e\n\nexport NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; + shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; }; 8DC349844744C81F79F94A1E /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; @@ -405,7 +405,7 @@ "$(inherited)", ); INFOPLIST_FILE = appTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -430,7 +430,7 @@ BUNDLE_LOADER = "$(TEST_HOST)"; COPY_PHASE_STRIP = NO; INFOPLIST_FILE = appTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -552,7 +552,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", @@ -616,7 +616,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", diff --git a/ios/app/AppDelegate.mm b/ios/app/AppDelegate.mm index c73bc099d6..268a1f8014 100644 --- a/ios/app/AppDelegate.mm +++ b/ios/app/AppDelegate.mm @@ -22,6 +22,8 @@ #import +static NSString *const kRNConcurrentRoot = @"concurrentRoot"; + @interface AppDelegate () { RCTTurboModuleManager *_turboModuleManager; RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; @@ -47,7 +49,8 @@ bridge.surfacePresenter = _bridgeAdapter.surfacePresenter; #endif - UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"xyz.blueskyweb.app", nil); + NSDictionary *initProps = [self prepareInitialProps]; + UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"RnDiffApp", initProps); if (@available(iOS 13.0, *)) { rootView.backgroundColor = [UIColor systemBackgroundColor]; @@ -67,6 +70,25 @@ return YES; } +/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off. +/// +/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html +/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). +/// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`. +- (BOOL)concurrentRootEnabled +{ + // Switch this bool to turn on and off the concurrent root + return true; +} +- (NSDictionary *)prepareInitialProps +{ + NSMutableDictionary *initProps = [NSMutableDictionary new]; +#ifdef RCT_NEW_ARCH_ENABLED + initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]); +#endif + return initProps; +} + - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG diff --git a/package.json b/package.json index 3e0afb334b..1cb6b9704a 100644 --- a/package.json +++ b/package.json @@ -29,10 +29,10 @@ "lru_map": "^0.4.1", "mobx": "^6.6.1", "mobx-react-lite": "^3.4.0", - "react": "17.0.2", + "react": "18.1.0", "react-circular-progressbar": "^2.1.0", "react-dom": "17.0.2", - "react-native": "0.68.2", + "react-native": "0.70.0", "react-native-appstate-hook": "^1.0.6", "react-native-gesture-handler": "^2.5.0", "react-native-image-crop-picker": "^0.38.1", @@ -68,10 +68,10 @@ "babel-plugin-react-native-web": "^0.17.7", "eslint": "^7.32.0", "jest": "^26.6.3", - "metro-react-native-babel-preset": "^0.67.0", + "metro-react-native-babel-preset": "^0.72.1", "react-native-dotenv": "^3.3.1", "react-scripts": "^5.0.1", - "react-test-renderer": "17.0.2", + "react-test-renderer": "18.1.0", "typescript": "^4.4.4" }, "resolutions": {