Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ios/ReactNativeBrownfield.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ReactNativeBrownfieldDelegate: RCTDefaultReactNativeFactoryDelegate {
initialProps: [AnyHashable: Any]?,
launchOptions: [AnyHashable: Any]? = nil
) -> UIView? {
reactNativeFactory?.rootViewFactory.view(
rootViewFactory?.view(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Lazy Initialization Timing Bug

The change to use a lazy rootViewFactory property introduces a timing issue. If view() is called before startReactNative(), rootViewFactory gets initialized to nil (as reactNativeFactory is not yet available). Since it's lazy, this nil value is permanently cached, preventing view() from ever returning a valid view, even after reactNativeFactory is later initialized.

Fix in Cursor Fix in Web

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats true, but either way the app will crash if startReactNative isn't called because ReactNativeViewController().view will be nil in that case

@okwasniewski what do you think is it a good idea to have a fallback UIView or the crash is indicative of integration error

withModuleName: moduleName,
initialProperties: initialProps,
launchOptions: launchOptions
Expand Down