mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Allow multiple RN instances to run at the same time (#49300)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49300 With the refactor of the AppDelegate in favor ReactNativeFactory, the users can now instantiate multiple instances of react native. However, currently, if you try to run multiple instances, the app will crash with the message: ``` libc++abi: terminating due to uncaught exception of type std::runtime_error: Feature flags cannot be overridden more than once ``` This happens also when the feature flags we would like to set are the same that we already applied. This should be an allowed scenario because reapplying the excatly same features flags should have no effect on React native and that's not the use case we want to forbid. With this change, we are creating a static variable that checks whether we already apply that set of feature flags and it allows you to create multiple instances by keeping the same flags ## Changelog: [iOS][Fixed] - Allow multiple RN instances to run at the same time Reviewed By: rubennorte Differential Revision: D69398441 fbshipit-source-id: a377c6a1402d38d66d348fa8c6a65e645973aadc
This commit is contained in:
committed by
Fabrizio Cucci
parent
9e664dc144
commit
7b088fa0b1
@@ -255,9 +255,12 @@ class RCTAppDelegateBridgelessFeatureFlags : public ReactNativeFeatureFlagsDefau
|
||||
|
||||
- (void)_setUpFeatureFlags
|
||||
{
|
||||
if ([self bridgelessEnabled]) {
|
||||
ReactNativeFeatureFlags::override(std::make_unique<RCTAppDelegateBridgelessFeatureFlags>());
|
||||
}
|
||||
static dispatch_once_t setupFeatureFlagsToken;
|
||||
dispatch_once(&setupFeatureFlagsToken, ^{
|
||||
if ([self bridgelessEnabled]) {
|
||||
ReactNativeFeatureFlags::override(std::make_unique<RCTAppDelegateBridgelessFeatureFlags>());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user