【发布时间】:2018-03-21 06:27:28
【问题描述】:
我一直在尝试使用我的应用实现 Snap Carousel。但它会给出以下警告并且不会加载。
错误:本机驱动的事件不支持侦听器。 在不变(invariant.js:38) 在新的 AnimatedEvent (AnimatedImplementation.js:2126) 在 Object.event (AnimatedImplementation.js:2230) 在新的轮播 (Carousel.js:147) 在 ReactCompositeComponentWrapper._constructComponentWithoutOwner (ReactCompositeComponent.js:296) 在 ReactCompositeComponentWrapper._constructComponent (ReactCompositeComponent.js:278) 在 ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:190) 在 Object.mountComponent (ReactReconciler.js:47) 在 Constructor.mountChildren (ReactMultiChild.js:240) 在 Constructor.initializeChildren (ReactNativeBaseComponent.js:69)
有轮播的类如下。
'use strict';
const styles = require('./Styles');
import React, {Component} from 'react';
import {
View
} from 'react-native';
import Carousel from 'react-native-snap-carousel';
export default class CarouselCard extends Component {
static renderItem({item, index}) {
console.log(item);
return item;
}
render() {
return (
<View key={this.props.cardKey}
style={[styles.cardContainer, {padding: 0, borderWidth: 0, marginRight: -10, marginLeft: -10}]}>
<Carousel
ref={(c) => {
this._carousel = c;
}}
data={this.props.cardsList}
renderItem={CampaignCard.renderItem}
sliderWidth={this.props.sliderWidth}
itemWidth={this.props.itemWidth}
useScrollView={true}
/>
</View>)
}
}
这个组件在父类中如下使用。
renderCarouselCards() {
let topCardsList = [];
for(let x = 0; x < this.state.campaigns.length; x++) {
topCardsList.push(
<CarouselCard
key={x}
cardKey={x}
cardsList={this.getTopCards(this.state.data[x])}
sliderWidth={Dimensions.get('window').width}
itemWidth={Dimensions.get('window').width - 20}
/>
)
}
return topCardsList;
}
//
render() {
return (
<ScrollView
contentInset={{top: 0}}
automaticallyAdjustContentInsets={false}
contentContainerStyle={styles.contentContainer}>
{this.renderCarouselCards()}
</ScrollView>
)
}
环境: 反应:15.3.1 反应原生:0.37.0 反应原生快照轮播:3.6.0
目标平台: iOS (11.2)
有什么解决方法吗?谢谢。
【问题讨论】:
-
现在有同样的问题,使用 RN 0.39。该版本可能比框架测试的版本旧。
标签: javascript reactjs react-native react-native-snap-carousel