/// This method controls whether the concurrentRootfeature 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;
}
🐛 Bug Report
-Can not run the app with Flipper. Always show me this error: Flipper.sonar (13): EXC_BAD_ACCESS (code=1, address=0x9)
Code AppDelegate.mm:
`#import "AppDelegate.h"
import <React/RCTBridge.h>
import <React/RCTBundleURLProvider.h>
import <React/RCTRootView.h>
import "RNSplashScreen.h"
import <React/RCTI18nUtil.h>
import <React/RCTAppSetupUtils.h>
import <React/RCTLinkingManager.h>
import <UserNotifications/UserNotifications.h>
import
import <React/RCTAppSetupUtils.h>
if RCT_NEW_ARCH_ENABLED
import <React/CoreModulesPlugins.h>
import <React/RCTCxxBridgeDelegate.h>
import <React/RCTFabricSurfaceHostingProxyRootView.h>
import <React/RCTSurfacePresenter.h>
import <React/RCTSurfacePresenterBridgeAdapter.h>
import <ReactCommon/RCTTurboModuleManager.h>
import <react/config/ReactNativeConfig.h>
static NSString *const kRNConcurrentRoot = @"concurrentRoot";
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> { RCTTurboModuleManager _turboModuleManager; RCTSurfacePresenterBridgeAdapter _bridgeAdapter; std::shared_ptr _reactNativeConfig;
facebook::react::ContextContainer::Shared _contextContainer;
}
@end
endif
@implementation AppDelegate
// Deep linking
// Deep Linking (universal links)
(BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions { [[RCTI18nUtil sharedInstance] allowRTL:YES]; // Firebase if ([FIRApp defaultApp] == nil) { [FIRApp configure]; } RCTAppSetupPrepareApp(application);
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
if RCT_NEW_ARCH_ENABLED
_contextContainer = std::make_shared();
_reactNativeConfig = std::make_shared();
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
endif
NSDictionary initProps = [self prepareInitialProps]; UIView rootView = RCTAppSetupDefaultRootView(bridge, @"", nil);
if (@available(iOS 13.0, *)) { rootView.backgroundColor = [UIColor systemBackgroundColor]; } else { rootView.backgroundColor = [UIColor whiteColor]; }
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; // Define UNUserNotificationCenter UNUserNotificationCenter center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self;
[self.window makeKeyAndVisible];
[RNSplashScreen show]; // here
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 theconcurrentRoot
feture is enabled. Otherwise, it returnsfalse
.(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; }
if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
endif
}
if RCT_NEW_ARCH_ENABLED
pragma mark - RCTCxxBridgeDelegate
pragma mark RCTTurboModuleManagerDelegate
(Class)getModuleClassFromName:(const char *)name { return RCTCoreModulesClassProvider(name); }
(std::shared_ptr)getTurboModule:(const std::string &)name
jsInvoker:(std::shared_ptr)jsInvoker
{
return nullptr;
}
(std::shared_ptr)getTurboModule:(const std::string &)name
initParams:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return nullptr;
}
(id)getModuleInstanceFromClass:(Class)moduleClass
{
return RCTAppSetupDefaultModuleFromClass(moduleClass);
}
endif
@end `
To Reproduce
I have this line in my PodFile: :flipper_configuration => FlipperConfiguration.enabled(["Debug"], { 'Flipper' => '0.166.0' }),
Environment