Remove dispatchesReanimatedEvent from initial config#4221
Open
m-bert wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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.dispatchesReanimatedEventsfrom a UI-thread SharedValue listener by computing the value on-the-fly duringrunOnJSupdates. - Stops including
dispatchesReanimatedEventsin the base “allowed props” whitelist, and instead injects it directly into the native-side config payload. - Removes the internal
dispatchesReanimatedEventsassignment fromresolveInternalConfigProps, 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.
j-piasecki
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The crash in #4216 was caused by worklets, which freezes objects when they are passed to the UI side. In our
Swipeableimplementationenabledis a SharedValue fortapgesture. 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
dispatchesReanimatedEventsfrom 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 toSharedValues' listeners, therefore we do not freeze config anymore.Fixes #4216
Test plan
Tested on example from #4216