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 (将#修改为@)