Skip to content

fix: ignore failed segment measurements - #923

Open
huytdps13400 wants to merge 1 commit into
react-native-segmented-control:masterfrom
huytdps13400:fix/ignore-failed-segment-measurements
Open

huytdps13400 wants to merge 1 commit into
react-native-segmented-control:masterfrom
huytdps13400:fix/ignore-failed-segment-measurements

Conversation

@huytdps13400

Copy link
Copy Markdown

Overview

An unsuccessful Android measure request can invoke its callback without arguments, as shown in React Native's MeasureOperation. The control currently divides the missing width by the number of segments and sends NaN to Animated.Value.setValue, including when that callback arrives after unmount.

Ignore measurements with an absent width. Successful measurements, including zero, still update the control. A failed measurement preserves the last valid segment width, and subsequent layout events continue to work. The callback type now reflects that width may be absent.

Fixes #897.

Test Plan

  • Component tests use the existing React Native Jest preset, capture the view's measurement callbacks, and inspect actual Animated value updates and rendered slider widths.
  • Before: 3 failed cases each send NaN to Animated; 4 control cases pass. After: all 7 tests pass, covering failure before layout, after a successful measurement, and after unmount, plus zero width, valid sizing, changing segment count, and recovery through onLayout.
  • TypeScript and full ESLint pass; the same 7 existing lint warnings remain. Prettier passes with --bracket-same-line, matching the repository's legacy formatting setting.
  • The source changes merge cleanly with fix: skip callbacks for the selected segment #922; all 16 tests pass with both fixes applied. Each PR independently adds the same Jest step to the existing CI job.
  • Flow cannot start locally because flow-bin 0.237.2 supplies an x86_64 macOS binary incompatible with this host (spawn error -86). No device/browser crash reproduction or Flow success is claimed; the failure callback and NaN propagation are verified at the component boundary.

@huytdps13400
huytdps13400 force-pushed the fix/ignore-failed-segment-measurements branch from abc5131 to 733e3c3 Compare October 5, 2026 06:54
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.

Android crash: "[160,"<<NaN>>"] is not usable as a native method argument"

1 participant