小编Ran*_*ynh的帖子

React Native Snap Carousel:不变违规:inputRange 必须单调递增 NaN,NaN,NaN

我对 React Native 很陌生,我正在尝试使用这个组件:https : //github.com/archriss/react-native-snap-carousel

我尝试使用他们在使用部分提供的代码来创建最简单的工作版本:

    return (
        <Carousel
          ref={(c) => { this._carousel = c; }}
          data={this.state.entries} // this seems to be the problem
          renderItem={this._renderItem}
          sliderWidth='100%'
          itemWidth='80%'
        />
    );
Run Code Online (Sandbox Code Playgroud)

其中“条目”是一个数组。这会导致以下错误:

Invariant Violation: inputRange must be monotonically increasing NaN,NaN,NaN
Run Code Online (Sandbox Code Playgroud)

编辑:这是 _renderItem 方法

_renderItem ({item, index}) {
    return (
        <View style={styles.slide}>
            <Text style={styles.title}>{ item.title }</Text>
        </View>
    );
  }
Run Code Online (Sandbox Code Playgroud)

react-native

6
推荐指数
2
解决办法
8791
查看次数

标签 统计

react-native ×1