react-native-swipeout onPress方法禁用包含组件的onPress方法

问题描述 投票:5回答:1

我有以下flatlist render方法,在点击列表项时,它将调用this._onPress方法:

render() {
      return (
      <TouchableOpacity  onPress={this._onPress} >
        <View style={styles.bookItem} >
          <Image style={styles.cover} source={{uri:this.props.coverURL}}/>
          <View style={styles.info} >
            <Text style={styles.title}>{this.props.title} </Text>
            <Text style={styles.author}>{this.props.author}</Text>
            <Text style={{height: 8}}/>
           </View>
           <View style={styles.rightIcon}>
                <Icon name="chevron-right" size={28} color={'#AAAAAA'} />
          </View>
        </View>
      </TouchableOpacity>
    );
  }

在我在以下代码中添加了swipeout标记后,swipeout可以正常工作,但点击一个项目不再调用this._onPress方法:

 render() {
    // Buttons
    var swipeoutBtns = [
      {
        text: 'Delete',
        onPress: this._buttonPress
      }
    ]
    return (
      <TouchableOpacity  onPress={this._onPress} >
      <Swipeout right={swipeoutBtns} >
        <View style={styles.bookItem} >
          <Image style={styles.cover} source={{uri:this.props.coverURL}}/>
          <View style={styles.info} >
            <Text style={styles.title}>{this.props.title} </Text>
            <Text style={styles.author}>{this.props.author}</Text>
            <Text style={{height: 8}}/>
           </View>
           <View style={styles.rightIcon}>
                <Icon name="chevron-right" size={28} color={'#AAAAAA'} />
          </View>
        </View>
      </Swipeout>
      </TouchableOpacity>
    );
  }

这是react-native-swipeout的限制吗?

react-native onpress
1个回答
1
投票

如果您将Swipeout作为第一个标记并可触摸为下一个嵌套标记,我认为它会起作用。但是,它似乎使Swipeout功能的响应性降低

© www.soinside.com 2019 - 2024. All rights reserved.