Skip to content

Commit 0532309

Browse files
authored
Fix Reanimated worklet recognition on Fabric (#2555)
## Description On the new architecture, a handler that is using reanimated worklet should be attached with an action type `REANIMATED_WORKLET`, so it will send an event directly to reanimatedEventDispatcher, instead of emitting an event on which reanimated should subscribe as it was on old architecture. Emitting and handling an event may fail in some cases, since handler might be an object based on type: `MutableRefObject<WorkletEventHandler<T> | null>` rather than a function. ## Test plan Tested on an example app named 'accordion' for Fabric from reanimated repo: https://github.com/software-mansion/react-native-reanimated/blob/main/app/src/examples/OldMeasureExample.tsx#L212
1 parent b502fc0 commit 0532309

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/handlers/createHandler.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,10 @@ export default function createHandler<
329329

330330
const actionType = (() => {
331331
if (
332-
this.props?.onGestureEvent &&
333-
'current' in this.props.onGestureEvent
332+
(this.props?.onGestureEvent &&
333+
'current' in this.props.onGestureEvent) ||
334+
(this.props?.onHandlerStateChange &&
335+
'current' in this.props.onHandlerStateChange)
334336
) {
335337
// Reanimated worklet
336338
return ActionType.REANIMATED_WORKLET;

0 commit comments

Comments
 (0)