diff --git a/.changeset/silly-wolves-thank.md b/.changeset/silly-wolves-thank.md new file mode 100644 index 00000000..0d828a0f --- /dev/null +++ b/.changeset/silly-wolves-thank.md @@ -0,0 +1,5 @@ +--- +'@callstack/react-native-brownfield': patch +--- + +fix: fix method to deallocate reactNativeFactory instance for expo diff --git a/apps/AppleApp/Brownfield Apple App/components/ContentView.swift b/apps/AppleApp/Brownfield Apple App/components/ContentView.swift index 067f44d3..1375dd08 100644 --- a/apps/AppleApp/Brownfield Apple App/components/ContentView.swift +++ b/apps/AppleApp/Brownfield Apple App/components/ContentView.swift @@ -33,13 +33,6 @@ struct ContentView: View { .navigationBarHidden(true) .clipShape(RoundedRectangle(cornerRadius: 16)) .background(Color(UIColor.systemBackground)) - - Button("Stop React Native") { - ReactNativeBrownfield.shared.stopReactNative() - } - .buttonStyle(PlainButtonStyle()) - .padding(.top) - .foregroundColor(.red) } .frame(maxWidth: .infinity, maxHeight: .infinity) .padding(16) diff --git a/apps/AppleApp/Brownfield Apple App/components/GreetingCard.swift b/apps/AppleApp/Brownfield Apple App/components/GreetingCard.swift index effcf841..125e4858 100644 --- a/apps/AppleApp/Brownfield Apple App/components/GreetingCard.swift +++ b/apps/AppleApp/Brownfield Apple App/components/GreetingCard.swift @@ -1,4 +1,5 @@ import SwiftUI +import ReactBrownfield import Brownie struct GreetingCard: View { @@ -17,10 +18,18 @@ struct GreetingCard: View { .multilineTextAlignment(.center) .font(.body) - Button("Increment counter") { - $counter.set { $0 + 1 } + + HStack { + Button("Increment counter") { + $counter.set { $0 + 1 } + } + .buttonStyle(.borderedProminent) + + Button("Stop RN") { + ReactNativeBrownfield.shared.stopReactNative() + } + .buttonStyle(.borderedProminent) } - .buttonStyle(.borderedProminent) } } } diff --git a/packages/react-native-brownfield/ios/Expo/ExpoHostRuntime.swift b/packages/react-native-brownfield/ios/Expo/ExpoHostRuntime.swift index 0d02cb31..c38eeb2d 100644 --- a/packages/react-native-brownfield/ios/Expo/ExpoHostRuntime.swift +++ b/packages/react-native-brownfield/ios/Expo/ExpoHostRuntime.swift @@ -65,6 +65,9 @@ final class ExpoHostRuntime { return } + if let rootViewFactory = reactNativeFactory?.rootViewFactory { + (rootViewFactory as AnyObject).setValue(nil, forKey: "reactHost") + } reactNativeFactory = nil expoDelegate = nil }