Skip to content

Commit a8b0154

Browse files
committed
.
1 parent 8cd276a commit a8b0154

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Third-Party Library Integration
22

3-
React Native Testing Library (RNTL) is designed to simulate core React Native behaviors.
3+
React Native Testing Library is designed to simulate core React Native behaviors.
44
However, it does not replicate the internal logic of third-party libraries. This guide
55
explains how to integrate your library with RNTL.
66

@@ -17,30 +17,32 @@ to expose custom events to RNTL's event subsystems. Both subsystems will first a
1717

1818
### Example: React Native Gesture Handler
1919

20-
React Native Gesture Handler (RNGH) provides a composite `Pressable` component with `onPress` props.
20+
React Native Gesture Handler (RNGH) provides a composite [Pressable](https://docs.swmansion.com/react-native-gesture-handler/docs/components/pressable/)
21+
component with `onPressXxx` props.
2122
These props are part of the library's internal event flow, which involves native modules and
2223
`EventEmitters`. As a result, they are not directly exposed to the host components rendered by
2324
`Pressable`, making them inaccessible to RNTL's event subsystems.
2425

25-
To enable RNTL to interact with RNGH's `Pressable` component, the library exposes `testOnly_onPress`
26+
To enable RNTL to interact with RNGH's `Pressable` component, the library exposes `testOnly_onPressXxx`
2627
props on the `NativeButton` host component rendered by `Pressable`. This allows RNTL to simulate
2728
interactions during testing.
2829

2930
```tsx title="Simplified RNGH Pressable component"
3031
function Pressable({ onPress, onPressIn, onPressOut, ... }) {
31-
// Component logic...
32-
33-
const isTestEnv = process.env.NODE_ENV === 'test';
34-
35-
return (
36-
<GestureDetector gesture={gesture}>
37-
<NativeButton
38-
{ /* Other props... */ }
39-
testOnly_onPress={isTestEnv ? onPress : undefined}
40-
testOnly_onPressIn={isTestEnv ? onPressIn : undefined}
41-
testOnly_onPressOut={isTestEnv ? onPressOut : undefined}
42-
/>
32+
33+
// Component logic...
34+
35+
const isTestEnv = process.env.NODE_ENV === 'test';
36+
37+
return (
38+
<GestureDetector gesture={gesture}>
39+
<NativeButton
40+
{ /* Other props... */ }
41+
testOnly_onPress={isTestEnv ? onPress : undefined}
42+
testOnly_onPressIn={isTestEnv ? onPressIn : undefined}
43+
testOnly_onPressOut={isTestEnv ? onPressOut : undefined}
44+
/>
4345
</GestureDetector>
44-
);
46+
);
4547
}
4648
```

0 commit comments

Comments
 (0)