Skip to content

Commit 8bc0cc2

Browse files
authored
refactor: detect fabric with RN$Bridgeless (#2722)
## Description Since 0.74 `RN$Bridgeless` is always defined in the global object and bridgeless mode isn't supported anymore. Therefore checking `RN$Bridgeless` for Fabric is safer than depending on `_IS_FABRIC` variable which we intend to remove in the future. `RN$Bridgeless` is added to `global` much faster than `_IS_FABRIC`. See software-mansion/react-native-reanimated#7043 ## Changes 👍 ## Screenshots / GIFs :shipit: ## Test code and steps to reproduce 🚀 ## Checklist - [x] Included code example that can be used to test this change - [x] Updated TS types - [x] Updated documentation: <!-- For adding new props to native-stack --> - [x] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [x] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [x] Ensured that CI passes
1 parent df7a7d1 commit 8bc0cc2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/gesture-handler/fabricUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { View } from 'react-native';
77
type LocalGlobal = typeof global & Record<string, unknown>;
88

99
export function isFabric() {
10-
return !!(global as LocalGlobal)._IS_FABRIC;
10+
return !!(global as LocalGlobal).RN$Bridgeless;
1111
}
1212

1313
export type ShadowNodeWrapper = {

src/reanimated/ReanimatedNativeStackScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const AnimatedScreen = Animated.createAnimatedComponent(
2525
// We use prop added to global by reanimated since it seems safer than the one from RN. See:
2626
// https://github.com/software-mansion/react-native-reanimated/blob/3fe8b35b05e82b2f2aefda1fb97799cf81e4b7bb/src/reanimated2/UpdateProps.ts#L46
2727
// @ts-expect-error nativeFabricUIManager is not yet included in the RN types
28-
const ENABLE_FABRIC = !!global?._IS_FABRIC;
28+
const ENABLE_FABRIC = !!global?.RN$Bridgeless;
2929

3030
const ReanimatedNativeStackScreen = React.forwardRef<
3131
typeof AnimatedScreen,

0 commit comments

Comments
 (0)