You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4e18d5f
Browse filesBrowse the repository at this point in the historyBrowse files
Remove disableReanimated prop from components (#4650)
## Description
A worklet callback passed to `RectButton` (or any `BaseButton`-based
component) with `disableReanimated={false}` moved the gesture onto the
Reanimated detector. `BaseButton` adds plain JS callbacks of its own
(`onBegin`, `onActivate`, `onDeactivate`, `onFinalize`), which then ran
on the UI runtime. In release this crashed on the first touch with
"Tried to synchronously call a Remote Function", in dev Reanimated's
`useHandler` threw at render.
Components never supported worklet callbacks, so this makes that
explicit:
- `createNativeWrapper` always sets `disableReanimated` to `true`,
whatever the caller passed.
- `disableReanimated` and `runOnJS` are removed from the wrapper prop
types. They are still routed to the gesture config so they do not leak
onto the wrapped view.
- Docs for buttons and wrapped components state that callbacks run on
the JS thread.
`Touchable` and `Pressable` are not affected: `Touchable` has no gesture
config surface, `Pressable` hard-codes `disableReanimated` on its hooks.
Closes#4628
## Test plan
- New test in api_v3.test.tsx: RectButton with a worklet onTouchesDown
and disableReanimated={false} stays on the plain detector and still
fires onPress.
- Reporter's gist in the empty example screen on an Android emulator:
all three buttons log on the JS thread, no crash.
Copy file name to clipboardExpand all lines: packages/docs-gesture-handler/docs/components/buttons.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,8 @@ Gesture Handler library exposes components that render native touchable elements
27
27
28
28
On top of that all the buttons are wrapped with [`Native gesture`](/docs/gestures/use-native-gesture) and therefore allow for all its [properties](/docs/gestures/use-native-gesture#config) to be applied to them.
29
29
30
+
Button callbacks always run on the JS thread. The Reanimated-specific configuration ([`disableReanimated`](/docs/fundamentals/reanimated-interactions#disablereanimated), [`runOnJS`](/docs/fundamentals/reanimated-interactions#runonjs)) is not available on buttons, and passing a worklet as a callback does not move it to the UI thread.
Copy file name to clipboardExpand all lines: packages/docs-gesture-handler/docs/components/wrapped-components.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@ sidebar_position: 5
7
7
8
8
Some components come with a [`Native`](/docs/gestures/use-native-gesture) gesture pre-applied. This allows them to participate in the gesture recognition process. Have a look at the example below.
9
9
10
+
The callbacks of the pre-applied gesture always run on the JS thread. The Reanimated-specific configuration ([`disableReanimated`](/docs/fundamentals/reanimated-interactions#disablereanimated), [`runOnJS`](/docs/fundamentals/reanimated-interactions#runonjs)) is not available on these components.
0 commit comments