-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent iOS bridgeless initialization from getting the wrong bridge #5953
Prevent iOS bridgeless initialization from getting the wrong bridge #5953
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I wonder if there's anything we can do to prevent us from using |
Why would you need that? This API is going to be deprecated and removed anyway, like everything that relates to the bridge. Also, it's always risky to depend on global things like this. See the comment for |
To prevent future us from using this API.
Okay, that sounds good |
I'm looking for a way to pass a bridge from It seems this code is not run in Fabric - (UIView*)view {
RNCNaverMapViewImpl* ret = [[RNCNaverMapViewImpl alloc] init];
ret.bridge = self.bridge;
return ret;
} Is there any example inject Note I need |
@mym0404 As far as I know, there is no way to achieve this. Fabric creates the view instance itself. I think this is intentional as the views shouldn't have any dependencies other than props in order to work properly with the view recycling mechanism. |
@tsapeta understood, thank you for response. |
## Description This PR fixes getting access to right bridge, because `currentBridge` method can return invalid pointer when more than one instance of react exists in the application. Same changes we made in the Reanimated - software-mansion/react-native-reanimated#5953 ## Test plan I tested FabricExample on iOS with/without bridge, after startup and after reload, and it seems to work.
…2146) Similar to software-mansion/react-native-reanimated#5953, using `[RCTBridge currentBridge]` may lead to the wrong bridge in apps that have multiple React instances, as is the case for expo-dev-client. This results in apps sometimes crashing when reloading the bundle after interacting with the DevMenu.
…oftware-mansion#2146) Similar to software-mansion/react-native-reanimated#5953, using `[RCTBridge currentBridge]` may lead to the wrong bridge in apps that have multiple React instances, as is the case for expo-dev-client. This results in apps sometimes crashing when reloading the bundle after interacting with the DevMenu.
Summary
As I pointed out here, using
[RCTBridge currentBridge]
may lead to the wrong bridge in apps that have multiple React instances, as is the case for expo-dev-client.react-native-reanimated/apple/REAModule.mm
Line 284 in 7e1a19e
Fixes #5497
Instead of using
[RCTBridge currentBridge]
we can just callself.bridge
and ensure the correct bridge is always usedTest plan
Run FabricExample app on iOS