Skip to content

Commit 907bccf

Browse files
authored
[Docs] Add migration example for relations with wrapped components (#4595)
## Description Discussion #4418 pointed out that the upgrade guide doesn't cover migrating `withRef` + `simultaneousHandlers` on wrapped components like `ScrollView`. This adds a short subsection under "Migrating relations" with a code comparison and a table mapping `simultaneousHandlers`, `waitFor` and `blocksHandlers` to `simultaneousWith`, `requireToFail` and `block`. Also makes the tables in the upgrade guide use `table-layout: fixed` so the two columns are split evenly. The rule is scoped to this page, all of its tables are two-column RNGH2 to RNGH3 maps. ## Test plan Read docs 🤓
1 parent d30f463 commit 907bccf

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎packages/docs-gesture-handler/docs/guides/upgrading-to-3.mdx‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,38 @@ Full changes are as follows:
238238
| `gesture.requireExternalGestureToFail` | `gesture.requireToFail` |
239239
| `gesture.blocksExternalGesture` | `gesture.block` |
240240

241+
### Relations with wrapped components
242+
243+
Previously, relation properties of [wrapped components](/docs/components/wrapped-components), such as `ScrollView`, accepted refs, so the gesture had to be assigned a ref using `withRef`. In Gesture Handler 3, those properties accept gesture objects directly, and `withRef` is no longer needed.
244+
245+
<CodeComparison
246+
label1={"RNGH 2"}
247+
label2={"RNGH 3"}
248+
code1={
249+
`const panRef = useRef();
250+
const pan = Gesture.Pan().withRef(panRef);
251+
252+
<GestureDetector gesture={pan}>
253+
<ScrollView simultaneousHandlers={panRef} />
254+
</GestureDetector>
255+
`}
256+
code2={
257+
`const pan = usePanGesture({});
258+
259+
<GestureDetector gesture={pan}>
260+
<ScrollView simultaneousWith={pan} />
261+
</GestureDetector>
262+
`}
263+
/>
264+
265+
Full changes are as follows:
266+
267+
| RNGH2 | RNGH3 |
268+
| ---------------------- | ---------------------- |
269+
| `simultaneousHandlers` | `simultaneousWith` |
270+
| `waitFor` | `requireToFail` |
271+
| `blocksHandlers` | `block` |
272+
241273

242274
## Migrating components relying on view hierarchy
243275

‎packages/docs-gesture-handler/src/css/overrides.css‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ table thead tr {
2828
border-bottom: 1px solid var(--ifm-table-border-color);
2929
}
3030

31+
/* Every table in the upgrade guide maps RNGH2 to RNGH3, so split the columns evenly. */
32+
.docs-doc-id-guides\/upgrading-to-3 table {
33+
table-layout: fixed;
34+
}
35+
3136
.platform-compatibility table {
3237
display: table;
3338
width: 100%;

0 commit comments

Comments
 (0)