React-native-snap-carousel: Carouse Item can't handle press event

Created on 16 Jan 2018  路  9Comments  路  Source: meliorence/react-native-snap-carousel

<View key={index} style={styles.slide}>
                <TouchableOpacity style={styles.slideInnerContainer} onPress={this.gotoPay} >
                    <Image
                        source={{ uri: item.url }}
                        style={styles.image}
                    />
                </TouchableOpacity>
 </View>

here is the renderItem code, when I click the item , it didn't give me any response

contribution? reproduction?

Most helpful comment

@oferRounds check your renderItem function. if it's somewhat like _renderItem ({item, index}) it should be changed like _renderItem = ({item, index}) =>

All 9 comments

鈿狅笍 You did not follow the contributing guidelines!

As stated in these:

:warning: You need to fill out the issue template. This step is mandatory! Not doing so will result in your issue getting closed. Don't take this personally if this happens, and feel free to open a new issue once you've gathered all the information required by the template.


Unless you provide a Snack example that reproduces the issue, we won't be able to help you and the issue will be closed.

Closing as no further feedback was provided.

I can confirm that a carousel item _can_ handle an onPress event - tested in 3.7.0

+1

check if your renderItem function is an arrow function or binded. that might cause this issue

Seeing this also, has anyone found the causes for this?

@JetQin did you find solution to this?

@oferRounds check your renderItem function. if it's somewhat like _renderItem ({item, index}) it should be changed like _renderItem = ({item, index}) =>

@yjb94 thanks! It seems ok as far as I can tell - wdyt?

<Carousel
              data = { this.props.policies }
              renderItem = { this.renderSlide }
              sliderWidth = { Dimensions.get('window').width }
              itemWidth = { ITEM_WIDTH }
              itemHeight = { ITEM_HEIGHT }
              ref = { this.onGetSliderRef }
              containerCustomStyle = { styles.slider }
              contentContainerCustomStyle = { styles.sliderContentContainer }
              loop = { true }
              onSnapToItem = { this.onSnapToItem }
 />
````

private renderSlide = ({ item }) => {
return (
key = { (item as TimeOffPolicyModel).type }
policy = { item } userGender = { this.props.userGender }
width = { ITEM_WIDTH } height = { ITEM_HEIGHT }
onRequestButtonPress = { this.onRequestTimeOffButtonPress }
/>
)
}
```

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SnowDang picture SnowDang  路  4Comments

siderakis picture siderakis  路  3Comments

amyogiji picture amyogiji  路  5Comments

codejet picture codejet  路  5Comments

duongkhoilinh picture duongkhoilinh  路  4Comments