Skip to content

Remove dispatchesReanimatedEvent from initial config#4221

Open
m-bert wants to merge 1 commit into
mainfrom
@mbert/remove-dispatchesReanimatedEvents
Open

Remove dispatchesReanimatedEvent from initial config#4221
m-bert wants to merge 1 commit into
mainfrom
@mbert/remove-dispatchesReanimatedEvents

Conversation

@m-bert
Copy link
Copy Markdown
Collaborator

@m-bert m-bert commented Jun 1, 2026

Description

The crash in #4216 was caused by worklets, which freezes objects when they are passed to the UI side. In our Swipeable implementation enabled is a SharedValue for tap gesture. Because of that, whole config is sent to the UI when bindSharedValues is called. Trying to modify this config, in that case adding another simultaneous handler, results in a crash.

To fix that, I've removed dispatchesReanimatedEvents from initial config and moved its assignment to right before passing the config to the UI. This way it is not a field in config object, so we don't have to update it. Now we don't have to pass config to SharedValues' listeners, therefore we do not freeze config anymore.

Fixes #4216

Test plan

Tested on example from #4216

Copilot AI review requested due to automatic review settings June 1, 2026 13:36
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 PR fixes a v3 Reanimated/SharedValue-related crash (reported in #4216) by ensuring dispatchesReanimatedEvents is no longer stored/mutated on the (potentially frozen) gesture config object, and is instead computed only at the point where a native config payload is produced or updated.

Changes:

  • Avoids mutating config.dispatchesReanimatedEvents from a UI-thread SharedValue listener by computing the value on-the-fly during runOnJS updates.
  • Stops including dispatchesReanimatedEvents in the base “allowed props” whitelist, and instead injects it directly into the native-side config payload.
  • Removes the internal dispatchesReanimatedEvents assignment from resolveInternalConfigProps, preventing it from becoming part of the shared config object.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts Computes dispatchesReanimatedEvents without mutating the shared config object inside SharedValue listeners.
packages/react-native-gesture-handler/src/v3/hooks/utils/propsWhiteList.ts Removes dispatchesReanimatedEvents from the allowed native prop whitelist so it’s not treated as a normal config field.
packages/react-native-gesture-handler/src/v3/hooks/utils/configUtils.ts Stops setting dispatchesReanimatedEvents on the config object; computes it when preparing the native config payload.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v3] Crash in Swipeable when adding new item

3 participants