v3 `usePanGesture`: `validateOffsetsArray` reads shared values during render (Reanimated warning in `__DEV__`)
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, react-native, typescript
Hướng nghiên cứu
Bắt đầu từ src/v3/hooks/gestures/pan/usePanGesture.ts, đặc biệt là validateOffsetsArray và lời gọi hàm này từ validatePanConfig; theo dõi cách Shared Values được định kiểu và chuyển tiếp bởi các listener hiện có. Xác nhận cảnh báo trong môi trường phát triển bằng cách tái hiện lỗi trong issue, sau đó thêm hoặc cập nhật một bài kiểm thử tập trung cho Shared Values trong activeOffsetX. Đồng thời xác minh rằng các offset số thông thường vẫn được xác thực chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
In __DEV__, usePanGesture calls validatePanConfig synchronously while rendering. validateOffsetsArray unpacks the array entries with maybeUnpackValue, which reads .value of a shared value. Reanimated then warns on every render:
[Reanimated] Reading from `value` during component render. Please ensure that you do not access the `value` property or use `get` method of a shared value while React is rendering a component.
Environment: react-native-gesture-handler 3.3.0 (code unchanged in 3.5.1), react-native-reanimated 4.7.1, Expo SDK 58, React Native 0.88.1, iOS 27.
Steps to reproduce:
const reach = useSharedValue(-40);
const pan = usePanGesture({ activeOffsetX: [reach, 20], onUpdate: () => {} });
Render the component in a dev build: the warning appears on every render (the types allow shared values inside these arrays via WithSharedValue).
Root cause: src/v3/hooks/gestures/pan/usePanGesture.ts:46-47 (maybeUnpackValue<number>(offsets[0]), called from validatePanConfig at line 57-60 and from the hook body at line 152).
Fix: validate only plain numbers; shared values are forwarded to the native side by the existing listeners anyway, so they are not validated at render time:
- const offsetStart = maybeUnpackValue<number>(offsets[0]);
- const offsetEnd = maybeUnpackValue<number>(offsets[1]);
-
- if (offsetStart > 0 || offsetEnd < 0) {
+ const [offsetStart, offsetEnd] = offsets;
+
+ if (
+ (typeof offsetStart === 'number' && offsetStart > 0) ||
+ (typeof offsetEnd === 'number' && offsetEnd < 0)
+ ) {
The maybeUnpackValue import (line 11) then becomes unused. Happy to send this as a PR.
- Ngôn ngữ chính
- TypeScript
- Star
- 6.8k
- Fork
- 1.1k
- Merge trung bình
- 4 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 22
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của software-mansion/react-native-gesture-handler
-
GestureDetector should bubble touches if all gestures fail (or some other generalized solution)Đang mởMissing repro Platform: Android Platform: iOS
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 39/100
software-mansion/react-native-gesture-handler#4714 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[Web] A pan that starts on a Pressable presses it when the mouse button is releasedCó thể đã có người làm @mokshupadhyay đã nhận 8 ngày trước. Đang mởPlatform: Web
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 57/100
software-mansion/react-native-gesture-handler#4713 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[iOS] Button press feedback invisible on quick taps when Reduce Motion is enabledCó thể đã có người làm @andreialecu đã nhận 13 ngày trước. Đang mởMissing info Platform: iOS Platform: MacOS
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
software-mansion/react-native-gesture-handler#4707 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[Android] Tapping a Text with a `VirtualGestureDetector` inside a `Touchable` presses the `Touchable` instead when the Text overflows its detectorCó thể đã có người làm @huytdps13400 đã nhận 3 ngày trước. Đang mởMissing info Platform: Android
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
software-mansion/react-native-gesture-handler#4706 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[Android] Native gesture docs: a wrapped ScrollView lets RNGH Pressable fire onPress after a swipeCó thể đã có người làm @stussysenik đã nhận 14 ngày trước. Đang mởPlatform: Android
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
software-mansion/react-native-gesture-handler#4703 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của software-mansion/react-native-gesture-handler
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
laststance/design-world#98 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: KCM True crimeĐang mởapproved check:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
triage: failed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
oxc-project/tsrs#1277 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ardia-browser/ardia#6798 ·
Maintainer thường phản hồi trong vòng 1 ngày