Skip to content

Commit

Permalink
Prevent iOS bridgeless initialization from getting the wrong bridge (#…
Browse files Browse the repository at this point in the history
…5953)

## Summary

As I pointed out
[here](#5901 (comment)),
using `[RCTBridge currentBridge]` may lead to the wrong bridge in apps
that have multiple React instances, as is the case for expo-dev-client.


https://github.com/software-mansion/react-native-reanimated/blob/7e1a19ed8190763456e96939eec71c2528c1eed4/apple/REAModule.mm#L284

Fixes #5497 

Instead of using `[RCTBridge currentBridge]` we can just call
`self.bridge` and ensure the correct bridge is always used

## Test plan

Run FabricExample app on iOS

Co-authored-by: Krzysztof Piaskowy <krzysztof.piaskowy@swmansion.com>
  • Loading branch information
gabrieldonadel and piaskowyk authored Apr 30, 2024
1 parent 67104b6 commit 2e729a7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion apple/REAModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ - (void)sendEventWithName:(NSString *)eventName body:(id)body
{
if (_isBridgeless) {
#if REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED)
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)[RCTBridge currentBridge];
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
auto &rnRuntime = *(jsi::Runtime *)cxxBridge.runtime;
auto executorFunction = ([executor = _runtimeExecutor](std::function<void(jsi::Runtime & runtime)> &&callback) {
// Convert to Objective-C block so it can be captured properly.
Expand Down

0 comments on commit 2e729a7

Please sign in to comment.