如何解决React Native 为什么会出现错误:× inputRange must be monotonically non-decreaseing 0,NaN,NaN,NaN?
我将两个带有导航的对象传递到屏幕“UebungenAnzeigen”。 比函数决定()决定用于显示的对象,取决于它是定义的还是未定义的。我必须将接收到的对象转换为数组以将其用于轮播。当我将转换后的数组传递给作为轮播基础的平面列表的道具时,我得到错误:
'× inputRange 必须是单调非递减的 0,NaN,NaN'
不知何故,当我使用 this.magicArray = Object.values( this.decidedobject);
时,编译器说我在一个索引为 0 的数组中有一个索引为 14 的数组,我不确定这是否是问题的一部分。
提前致谢
import * as React from 'react';
import {
View,imagebackground,FlatList,TouchableWithoutFeedback,TouchableOpacity,Dimensions
} from 'react-native';
export default class UebungenAnzeige extends React.Component {
constructor(props) {
super(props);
this.state = {
title: '',erklaerung:'',dauer:'',};
//receive the data
//the random asanas from the system
this.asanas = this.props.route.params.asanas;
//the system picked by the user
this.eigeneasanas = this.props.route.params;
//decide returns a JSON
this.decidedobject=this.decide();
console.log(this.decidedobject);
//But we need an array for the flatlist so we got to convert it
this.magicArray = Object.values( this.decidedobject);
//check
console.log(this.magicArray);
//this.itemWidth = Dimensions.get('window').width;
//this.itemHeight = Dimensions.get('window').height;
//to decide between eigeneasanas and the random asanas chosen by the system
decide() {
if(this.eigeneasanas=='undefinded'){
return this.asanas;
}
return this.eigeneasanas;
}
keyExtractor = (item,index) => index.toString();
renderCarousel = ({item}) => (
<Card>
<TouchableWithoutFeedback
onPress={() => {
this.setState({
title: item.name,erklaerung: item.erklaerung,dauer: item.dauer,});
this.props.onCarouselPress;
}}
<TouchableOpacity onPress= {() => this.props.navigation.navigate('Uebungen')}>
Go
</TouchableOpacity>
</View>
</TouchableWithoutFeedback>
<View>
<TouchableOpacity onPress= {() => this.props.navigation.navigate('PlanBeenden')}>Praxis beenden</TouchableOpacity>
</View>
</Card>
);
render() {
return (
<View >
<FlatList
horizontal
showsHorizontalScrollIndicator={false}
keyExtractor={this.keyExtractor}
data={this.magicArray}
renderItem={this.renderCarousel}
itemWidth={450}
itemheight={1000}
/>
</View>
);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。