Im using the following library:
https://github.com/react-native-segmented-control/segmented-control
Iv followed the instructions to install it and everything is displaying fine, but I can't get the value to change or keep state to record the value:
const [gender, setGender] = useState(0)
<View style={styles.segmentContainer}>
<SegmentedControl
values={['Male', 'Female']}
style={{height: 40}}
fontStyle={styles.fontStyle}
selectedIndex={gender}
onChange={(event) => {
setGender({selectedIndex: event.nativeEvent.selectedSegmentIndex});
}}
/>
</View>
I have imported:
import { event } from 'react-native-reanimated';
Every time I click on the other option the app crashes with the following:
Invariant Violation: [18,472,{"type":"frames","frames":[0,0.10802469135802473,0.2098765432098766,0.30555555555555547,0.3950617283950617,0.4783950617283951,0.5555555555555555,0.6265432098765431,0.691358024691358,0.75,0.8024691358024691,0.8487654320987654,0.8888888888888888,0.9228395061728395,0.9506172839506173,0.9722222222222222,0.9876543209876543,0.9969135802469136,1],"toValue":"<<NaN>>","iterations":1},10261] is not usable as a native method argument
This error is located at:
in RootErrorBoundary (created by ExpoRoot)
in ExpoRoot (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)
question from:
https://stackoverflow.com/questions/65917826/segmented-controls-react-native 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…