Repository navigation
Bump react-native-gesture-handler to 3.3.0 #102678
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
Changes from all commits
d923b1e
be4673e
d688dd3
1921e1d
61508f3
2d7d39d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,14 @@ Object.assign(global, {TextDecoder, TextEncoder}); | |
| // https://reactnavigation.org/docs/testing/#mocking-native-modules | ||
| jest.mock('react-native/src/private/animated/NativeAnimatedHelper'); | ||
|
|
||
| // Gesture Handler 3 throws in __DEV__ when a GestureDetector has no GestureHandlerRootView above it. In the app every screen | ||
| // renders under the root view in App.tsx, but tests render screens on their own, so the context pretends a root view is always present. | ||
| // Jest resolves the package through `main` (lib/module), so the compiled file is the one to mock. | ||
| jest.mock('react-native-gesture-handler/lib/module/GestureHandlerRootViewContext', () => ({ | ||
| __esModule: true, | ||
| default: jest.requireActual<typeof React>('react').createContext(true), | ||
| })); | ||
|
|
||
| // Mock react-native-onyx storage layer because the SQLite storage layer doesn't work in jest. | ||
| // Mocking this file in __mocks__ does not work because jest doesn't support mocking files that are not directly used in the testing project, | ||
| // and we only want to mock the storage layer, not the whole Onyx module. | ||
|
|
@@ -144,6 +152,11 @@ jest.mock('react-native-reanimated', () => ({ | |
| // react-native-reanimated/mock leaves dispatchCommand out (see its own "ADD ME IF NEEDED" comment). forceClearInput | ||
| // (src/libs/ComponentUtils) dispatches it from a UI-thread worklet, so any test exercising that path needs it mocked. | ||
| dispatchCommand: jest.fn(), | ||
| // react-native-reanimated/mock also leaves out useComposedEventHandler, useHandler and isSharedValue, which Gesture Handler 3 | ||
| // calls from its detectors (including the ones behind its ScrollView / FlatList wrappers). | ||
| useComposedEventHandler: jest.fn(() => () => {}), | ||
| useHandler: jest.fn(() => ({context: {}, doDependenciesDiffer: false})), | ||
| isSharedValue: jest.fn((value: unknown) => typeof value === 'object' && value !== null && 'value' in value && 'get' in value && typeof value.get === 'function'), | ||
|
Comment on lines
+157
to
+159
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These will be unnecessary after #102266.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, good catch. I guess let's leave my mock, then, if the PR with the gesture handler bump gets merged before the reanimated one, I'll remove these lines in the reanimated bump. If not, I'll remove them here |
||
| useReducedMotion: jest.fn, | ||
| useScrollViewOffset: jest.fn(() => 0), | ||
| useAnimatedRef: jest.fn(() => jest.fn()), | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Why do we need so many new entries here? 👀
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.
The entire builder API in RNGH 3 is marked as deprecated in favor of the new hook API, that’s why the linter is throwing errors. The 3.x builder API still works, but moving to hooks requires rewriting gesture logic, so I think it would be better to split this bump into two or more PRs
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.
@collectioneur Should we do that in a follow up? Happy to create new issues for that
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.
Yes, I think a new issue would be more suitable for that, thanks!