Skip to content

Commit

Permalink
Get right bridge (#2886)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
piaskowyk authored May 9, 2024
1 parent 030cf73 commit 81a7df0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions apple/RNGestureHandlerModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ @implementation RNGestureHandlerModule {

#ifdef RCT_NEW_ARCH_ENABLED
@synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
@synthesize bridge = _bridge;
@synthesize dispatchToJSThread = _dispatchToJSThread;
#endif // RCT_NEW_ARCH_ENABLED

Expand Down Expand Up @@ -133,14 +132,14 @@ - (void)setBridge:(RCTBridge *)bridge
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
{
dispatch_block_t block = ^{
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)[RCTBridge currentBridge];
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
auto runtime = (jsi::Runtime *)cxxBridge.runtime;
decorateRuntime(*runtime);
};
if (_dispatchToJSThread) {
_dispatchToJSThread(block);
} else {
[[RCTBridge currentBridge] dispatchBlock:block queue:RCTJSThread];
[self.bridge dispatchBlock:block queue:RCTJSThread];
}

return @true;
Expand Down

0 comments on commit 81a7df0

Please sign in to comment.