React native 使用本机基关闭FlatList内的SwipeRow

React native 使用本机基关闭FlatList内的SwipeRow,react-native,native-base,React Native,Native Base,如何关闭公寓列表内的SwipeRow 这对于ListView来说是一件容易的事情,但是由于下一个版本将使用FlatList,所以它应该是可能的 从他们的源代码来看,似乎还没有实现。你能试试这个吗 import React, { Component } from 'react'; import { FlatList } from 'react-native'; import { Container, Header, Content, SwipeRow, View, Text, Icon, Butt

如何关闭公寓列表内的SwipeRow

这对于ListView来说是一件容易的事情,但是由于下一个版本将使用FlatList,所以它应该是可能的

从他们的源代码来看,似乎还没有实现。

你能试试这个吗

import React, { Component } from 'react';
import { FlatList } from 'react-native';
import { Container, Header, Content, SwipeRow, View, Text, Icon, Button } from 'native-base';

export default class App extends Component {
  constructor(props) {
    super(props)
    this.state = { data: [{ key: 'a' }, { key: 'b' }] }
    this.component = [];
    this.selectedRow;
  }
  render() {
    return (
      <Container>
        <Header />
        <Content>
          <FlatList
            data={[{ key: 'a', value: 'Row one' }, { key: 'b', value: 'Row two' }, { key: 'c', value: 'Row three' }, { key: 'd', value: 'Row four' }, { key: 'e', value: 'Row five' }]}
            keyExtractor={(item) => item.key}
            renderItem={({ item }) => <SwipeRow
              ref={(c) => { this.component[item.key] = c }}
              leftOpenValue={75}
              rightOpenValue={-75}
              onRowOpen={() => {
                if (this.selectedRow && this.selectedRow !== this.component[item.key]) { this.selectedRow._root.closeRow(); }
                this.selectedRow = this.component[item.key]
              }}
              left={
                <Button success onPress={() => alert('Add')}>
                  <Icon active name="add" />
                </Button>
              }
              body={
                <View style={{ paddingLeft: 20 }}>
                  <Text>{item.value}</Text>
                </View>
              }
              right={
                <Button danger onPress={() => alert('Delete')}>
                  <Icon active name="trash" />
                </Button>
              }
            />}
          />
          <Button style={{ margin: 20 }} onPress={() => this.selectedRow._root.closeRow()}><Text>Close row</Text></Button>
        </Content>
      </Container>
    );
  }
}
import React,{Component}来自'React';
从“react native”导入{FlatList};
从“本机基础”导入{容器、标题、内容、开关、视图、文本、图标、按钮};
导出默认类应用程序扩展组件{
建造师(道具){
超级(道具)
this.state={data:[{key:'a'},{key:'b'}]}
this.component=[];
这是我选择的;
}
render(){
返回(
item.key}
renderItem={({item})=>{this.component[item.key]=c}
leftOpenValue={75}
rightOpenValue={-75}
onRowOpen={()=>{
如果(this.selectedRow&&this.selectedRow!==this.component[item.key]){this.selectedRow.\u root.closeRow();}
this.selectedRow=this.component[item.key]
}}
左={
警报('Add')}>
}
身体={
{item.value}
}
对={
警报('Delete')}>
}
/>}
/>
this.selectedRow.\u root.closeRow()}>关闭行
);
}
}

你是个十足的野兽!谢谢你,好心的先生。!这应该作为答案。getting error
TypeError:undefined不是一个对象(评估'This.\u panResponder.panHandlers')
@chiragprajapati SwipeRow已从v2.13.0以后的本机库中删除。