reactjs - 分段控件 React Native
问题描述
我使用以下库:
https://github.com/react-native-segmented-control/segmented-control
Iv 按照说明进行安装,一切正常,但我无法更改值或保持状态以记录值:
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>
我已经导入:
import { event } from 'react-native-reanimated';
每次我单击另一个选项时,应用程序都会崩溃并显示以下内容:
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)
解决方案
推荐阅读
- javascript - 从需要时间计算的函数中获取数据
- r - 在 Windows 上使用 fread (data.table) 或 read.csv 将希伯来语文本读入 R
- powershell - 基于模式匹配插入多行的 Powershell 脚本
- java - 不支持的 major.minor 版本 52.0 NetBeans Apache 12.2
- python - 如何从 models.py 调用函数到视图或模板
- reactjs - 在嵌套 if/else 语句中使用 prevProps 时,如何将 componentDidUpdate 转换为 useEffect?
- c# - 如何将 PHP 代码中的嵌套数组转换为 c#
- django - 表单 Django Python
- node.js - 将变量传递给 npm 命令字符串(不是 npm 命令运行的脚本)
- linux - “主机名 -i”的错误