-
-
Notifications
You must be signed in to change notification settings - Fork 1k
[docs] Update docs #3959
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
base: main
Are you sure you want to change the base?
[docs] Update docs #3959
Conversation
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.
Pull request overview
This pull request updates and standardizes the documentation across the react-native-gesture-handler project. The changes focus on improving consistency, correcting links, fixing formatting issues, and reorganizing content for better readability. The documentation structure has been updated to reflect the new monorepo layout where docs are now located in packages/docs-gesture-handler/.
Changes:
- Updated repository paths and edit URLs to reflect new
packages/docs-gesture-handler/structure - Improved documentation consistency by adding internal links, reorganizing sections, and wrapping code examples with CollapsibleCode components
- Enhanced cross-referencing between related documentation pages with hyperlinks
- Added support for Groovy syntax highlighting for Android code blocks
- Standardized formatting and improved readability across troubleshooting, testing, installation, and gesture composition guides
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/docs-gesture-handler/docusaurus.config.js | Updated editUrl path to new monorepo structure and added groovy language support |
| packages/docs-gesture-handler/docs/guides/troubleshooting.mdx | Reorganized content, added Tabs for package managers, improved formatting and wording |
| packages/docs-gesture-handler/docs/guides/testing.md | Restructured API documentation, improved descriptions, added links to examples |
| packages/docs-gesture-handler/docs/guides/quickstart/index.md | Added target="_blank" to external Reanimated documentation link |
| packages/docs-gesture-handler/docs/fundamentals/state-manager.mdx | Added hyperlink to gesture lifecycle documentation |
| packages/docs-gesture-handler/docs/fundamentals/reanimated-interactions.mdx | Added links and removed backticks from plain text "Reanimated" mentions |
| packages/docs-gesture-handler/docs/fundamentals/introduction.md | Added links to specific gesture types and updated documentation repository path |
| packages/docs-gesture-handler/docs/fundamentals/installation.mdx | Reorganized sections, added macOS instructions, improved clarity of setup steps |
| packages/docs-gesture-handler/docs/fundamentals/gesture-detector.mdx | Fixed touchAction type definition, improved SVG example, updated Reanimated link |
| packages/docs-gesture-handler/docs/fundamentals/gesture-composition.mdx | Wrapped examples with CollapsibleCode, imported simultaneous example from external file |
| packages/docs-gesture-handler/docs/fundamentals/callbacks-events.mdx | Removed backticks from "Reanimated" in plain text |
| packages/docs-gesture-handler/docs/fundamentals/animated-interactions.mdx | Added links to callback documentation and useNativeDriver reference |
| packages/docs-gesture-handler/docs/fundamentals/_examples/simultaneous.tsx | New example file for simultaneous gestures demonstration |
Comments suppressed due to low confidence (4)
packages/docs-gesture-handler/docs/guides/troubleshooting.mdx:14
- Incorrect capitalization: "Github" should be "GitHub" (capital H and capital B) to match the correct brand name.
packages/docs-gesture-handler/docs/guides/troubleshooting.mdx:25 - Incorrect capitalization: "Github" should be "GitHub" (capital H and capital B) to match the correct brand name.
packages/docs-gesture-handler/docs/fundamentals/gesture-composition.mdx:9 - The import path contains a double slash and escaped underscores. Based on other raw-loader imports in the codebase (e.g., in use-pan-gesture.mdx, use-tap-gesture.mdx), the path should use a single slash and unescaped underscores. The correct path should be './_examples/simultaneous'.
packages/docs-gesture-handler/docs/guides/troubleshooting.mdx:65 - The bash code block has inconsistent indentation. It has 6 spaces of indentation while other code blocks in the same TabItem have 4 spaces. This should be consistent with the surrounding code blocks for proper formatting.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/docs-gesture-handler/docs/fundamentals/gesture-detector.mdx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…or.mdx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| <GestureDetector gesture={panGesture}> | ||
| <ReanimatedSwipeable simultaneousWithExternalGesture={panGesture} /> | ||
| </GestureDetector> | ||
| </GestureDetector>; |
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?
| @@ -0,0 +1,95 @@ | |||
| import { StyleSheet } from 'react-native'; | |||
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.
It may make sense to extract all of the examples in this case.
| ## Gesture Detector | ||
|
|
||
| The `GestureDetector` is a key component of `react-native-gesture-handler`. It supports gestures created either using the hooks API or the builder pattern. Additionally, it allows for the recognition of multiple gestures through [gesture composition](/docs/fundamentals/gesture-composition). `GestureDetector` interacts closely with [`Reanimated`](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/). For more details, refer to the [Integration with Reanimated](/docs/fundamentals/reanimated-interactions) section. | ||
| The `GestureDetector` is a key component of `react-native-gesture-handler`. It supports gestures created either using the hook API or the builder pattern. Additionally, it allows for the recognition of multiple gestures through [gesture composition](/docs/fundamentals/gesture-composition). `GestureDetector` interacts closely with [`Reanimated`](https://docs.swmansion.com/react-native-reanimated/). For more details, refer to the [Integration with Reanimated](/docs/fundamentals/reanimated-interactions) section. |
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 `GestureDetector` is a key component of `react-native-gesture-handler`. It supports gestures created either using the hook API or the builder pattern. Additionally, it allows for the recognition of multiple gestures through [gesture composition](/docs/fundamentals/gesture-composition). `GestureDetector` interacts closely with [`Reanimated`](https://docs.swmansion.com/react-native-reanimated/). For more details, refer to the [Integration with Reanimated](/docs/fundamentals/reanimated-interactions) section. | |
| The `GestureDetector` is a key component of `react-native-gesture-handler`. It supports gestures created either using the hook-based API or the builder pattern. Additionally, it allows for the recognition of multiple gestures through [gesture composition](/docs/fundamentals/gesture-composition). `GestureDetector` interacts closely with [`Reanimated`](https://docs.swmansion.com/react-native-reanimated/). For more details, refer to the [Integration with Reanimated](/docs/fundamentals/reanimated-interactions) section. |
| In order to fully utilize the [touch events](/docs/gestures/touch-events/) you also need to use `react-native-reanimated` 2.3.0 or newer. | ||
| ### Running gestures on the UI thread | ||
|
|
||
| In order to run gestures on the UI thread, you also have to install [`react-native-reanimated`](https://docs.swmansion.com/react-native-reanimated/) along with [`react-native-worklets`](https://docs.swmansion.com/react-native-worklets/). |
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.
That's not entirely true - gestures always run on the ui thread. Reanimated (and Animated with native driver) allows responding to events from gestures on the UI thread.
| If you don't provide anything to the `styles` prop, it will default to `flex: 1`. If you want to customize the styling of the root view, don't forget to also include `flex: 1` in the custom style, otherwise your app won't render anything. Keep `GestureHandlerRootView` as close to the actual root of the app as possible. It's the entry point for all gestures and all gesture relations. The gestures won't be recognized outside of the root view, and relations only work between gestures mounted under the same root view. | ||
| If you don't provide anything to the `styles` prop, it will default to `flex: 1`. If you want to customize the styling of the root view, don't forget to also include `flex: 1` in the custom style, otherwise your app won't render anything. | ||
|
|
||
| If you're unsure if one of your dependencies already renders `GestureHandlerRootView` on its own, don't worry and add one at the root anyway. In case of nested root views, Gesture Handler will only use the top-most one and ignore the nested ones. |
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.
| If you're unsure if one of your dependencies already renders `GestureHandlerRootView` on its own, don't worry and add one at the root anyway. In case of nested root views, Gesture Handler will only use the top-most one and ignore the nested ones. | |
| If you're unsure if one of your dependencies already renders `GestureHandlerRootView` on its own, don't worry and add one at the root anyway. In case of nested root views, Gesture Handler will only use the top-most one and ignore the nested ones by default. |
Do we want to mention the unstable_forceActive prop?
| ## State management | ||
|
|
||
| Manual state management is based on `handlerTag`. There are two ways of manual state control. | ||
| Manual state management is based on `handlerTag`. There are two ways of manual state control. Some gestures also support [`manualActivation`](#manualactivation) property, which blocks their automatic activation, event if they met specific criteria. |
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.
| Manual state management is based on `handlerTag`. There are two ways of manual state control. Some gestures also support [`manualActivation`](#manualactivation) property, which blocks their automatic activation, event if they met specific criteria. | |
| Manual state management is based on `handlerTag`. There are two ways of manual state control. Some gestures also support [`manualActivation`](#manualactivation) property, which blocks their automatic activation, even if they meet their activation criteria. |
| ### Inside gesture definition | ||
|
|
||
| If you want to manipulate gesture's state in its callbacks, you can get `handlerTag` from event parameter. | ||
| If you want to manipulate gesture's state in its callbacks, you can get `handlerTag` from event parameter. |
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.
| If you want to manipulate gesture's state in its callbacks, you can get `handlerTag` from event parameter. | |
| If you want to manipulate gesture's state in its callbacks, you can get `handlerTag` from event parameter. |
| ```ts | ||
| direction: Directions | SharedValue<Directions>; | ||
| ``` |
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.
Was leaving that intentional?
| When used, the native component should be the direct child of a [`GestureDetector`](/docs/fundamentals/gesture-detectors#gesture-detector). | ||
|
|
||
| :::danger | ||
| Do not use `Native` gesture with components exported by React Native Gesture Handler, as they already have it preapplied. Attaching `Native` gesture twice will likely result in the components not working as intended. |
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.
| Do not use `Native` gesture with components exported by React Native Gesture Handler, as they already have it preapplied. Attaching `Native` gesture twice will likely result in the components not working as intended. | |
| Do not use `Native` gesture with components exported by React Native Gesture Handler, as they already have it pre-applied. Attaching `Native` gesture twice will result in undefined behavior. |
| The gesture activates when fingers are placed on the screen and rotate around a common point. It provides information such as the amount [rotated](#rotation), the focal point of the rotation ([anchor](#anchorx)), and its instantaneous [velocity](#velocity). | ||
|
|
||
| :::note | ||
| When implementing rotation based on `anchor` point, make sure to use it after the gesture had activated, i.e. in `onActivate` or `onUpdate` callbacks. Using it in `onBegin` may lead to unexpected behavior. |
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.
How hard would it be to hide those fields from onBegin?
Description
In this PR, I go through each section and make sure that everything is in the same style, has correct information and there are no broken links.
Test plan
Read docs 🤓