@@ -70,6 +70,7 @@ class ReactNativeBrownfieldDelegate: RCTDefaultReactNativeFactoryDelegate {
70
70
* Default value: nil
71
71
*/
72
72
private var reactNativeFactory : RCTReactNativeFactory ? = nil
73
+ private var hasStartedReactNative = false
73
74
74
75
private var factory : RCTReactNativeFactory ? {
75
76
if let existingFactory = reactNativeFactory {
@@ -125,8 +126,8 @@ class ReactNativeBrownfieldDelegate: RCTDefaultReactNativeFactoryDelegate {
125
126
* @param launchOptions Launch options, typically passed from AppDelegate.
126
127
*/
127
128
@objc public func startReactNative( onBundleLoaded: ( ( ) -> Void ) ? , launchOptions: [ AnyHashable : Any ] ? ) {
128
- guard reactNativeFactory == nil else { return }
129
- _ = factory
129
+ guard !hasStartedReactNative else { return }
130
+ guard factory != nil else { return }
130
131
131
132
if let onBundleLoaded {
132
133
self . onBundleLoaded = onBundleLoaded
@@ -146,6 +147,8 @@ class ReactNativeBrownfieldDelegate: RCTDefaultReactNativeFactoryDelegate {
146
147
)
147
148
}
148
149
}
150
+
151
+ hasStartedReactNative = true
149
152
}
150
153
151
154
/**
@@ -157,13 +160,17 @@ class ReactNativeBrownfieldDelegate: RCTDefaultReactNativeFactoryDelegate {
157
160
return
158
161
}
159
162
160
- guard let factory = reactNativeFactory else { return }
163
+ guard let factory = reactNativeFactory else {
164
+ hasStartedReactNative = false
165
+ return
166
+ }
161
167
162
168
factory. bridge? . invalidate ( )
163
169
164
170
NotificationCenter . default. removeObserver ( self )
165
171
onBundleLoaded = nil
166
172
173
+ hasStartedReactNative = false
167
174
reactNativeFactory = nil
168
175
}
169
176
0 commit comments