Repository navigation
Re-send SharedValue config values from the UI thread after binding - #4538
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The delayed binding can outlive effect cleanup, and the new resend behavior lacks regression coverage.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
This PR prevents stale SharedValue values from overwriting newer UI-thread updates during v3 gesture configuration.
Changes:
- Re-sends current values after binding listeners.
- Orders binding after full native configuration.
- Clarifies asynchronous native updates.
| File | Description |
|---|---|
NativeProxy.ts |
Updates the native update comment. |
reanimatedUtils.ts |
Adds typed listeners and initial value resend. |
useGesture.ts |
Queues binding after full configuration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


Summary
A gesture config value backed by a
SharedValuecould end up stale on the native side.useGesturereadssharedValue.valueon the JS thread when it prepares the full config and sends it asynchronously. The listener that forwards later writes is attached on the UI thread in a separate microtask. A write made on the UI thread between that read and the attach is never sent, and the full config lands with the old value. On re-renders the previous listener still forwards the write, but the full config and the partial update are issued from two threads and whichever lands last wins.Changes in this PR:
bindSharedValuessends the SharedValue's current value through the listener body right afteraddListener, from the UI thread. That covers a write made before the listener existed and makes the UI-thread read the last write for the key. The listener body is a generic over the SharedValue type.useGesturebinds from the same flushed batch assetGestureHandlerConfig, right after it, so the re-send can't be dispatched before the full config on any code path.NativeProxy.updateGestureHandlerConfigcomment no longer claims the update is flushed immediately.Dropping SharedValue keys from the full config instead is not an option:
setConfigresets absent keys to their defaults on every platform.Test plan
Tested on the following code: