react-native-snap-carousel returns "Cannot read property 'concat' of undefined" 当我使用 renderItme

react-native-snap-carousel returns "Cannot read property 'concat' of undefined" when I use renderItme

我正在学习 React-Native 并在我的项目中使用 react-native-snap-carousel。 我想显示一些图片,但出现错误 Cannot read property 'concat' of undefined

这是我的代码。

const HomePage = (props) => {
   let imageList = ['../images/index-bg.png', '../images/down.png'];

   const renderImage = ({ item, index }) => {
       return (
            <View>
                <Image source={require(item)}></Image>
            </View>
        )
    };

   return (
     <View> 
            <Carousel
                loop={true}
                autoplay={true}
                data={imageList}
                renderItem={renderImage}
                sliderWidth={pxToDp(50)}
                itemWidth={pxToDp(100)}
            />

     </View>
   )

}

如果我改变

          <View>
                <Image source={require(item)}></Image>
            </View>

          <View>
                <Image source={'../images/index-bg.png'}></Image>
            </View>
···
it works well


I expect it would work like [Usage](https://github.com/archriss/react-native-snap-carousel) but it doesn't work.

你试过吗?

let imageList = [require('../images/index-bg.png'), require('../images/down.png')];

然后

  <View>
    <Image source={item}></Image>
  </View>

必须在运行前定义 RN 中图像所需的来源

如果有效请告诉我!