machadogj / react-native-carousel-control

React Native Carousel control with support for iOS and Android
MIT License
247 stars 55 forks source link

onPress() not working in dynamic carousel child #38

Open davidcort opened 5 years ago

davidcort commented 5 years ago

`<Carousel pageStyle={{ overflow: Platform.OS == 'android' ? 'hidden' : 'visible', height: 285, elevation: 8, shadowColor: '#666666', shadowRadius: 9, shadowOpacity: 0.2, shadowOffset: { width: 0, height: 3 }, borderBottomLeftRadius: 20, borderBottomRightRadius: 20 }} pageWidth={width - 80} swipeThreshold={0.1}> { dataMagazine.map((item, i) => ( <View key={i} style={{flex: 1, height: 'auto'}} onPress={()=> alert('clicked !!') }>

                        <Image 
                            style={{
                                    flex: 1, 
                                    resizeMode: 'stretch',
                                    backgroundColor: '#FFFFFF'
                                }}
                            source={{uri: `${uri}${item.imagen_principal}`}}
                            onPress={() => this.goToNote(item)}
                        />
                        <MagazineTextContainer>
                            <LabelCategory>
                                {item.desc_categoria.toUpperCase()}
                            </LabelCategory>
                            <MagazineText>{item.titulo}</MagazineText>
                        </MagazineTextContainer>

                    </View>
                ))
            }
            </Carousel>`
rollsroyc3 commented 4 years ago

Im guessing you've moved on but onPress doesn't work with views.

davidcort commented 4 years ago

@rollsroyc3 you are right. This needed a TouchableOpacity or HighlitOpacity