首页 > 解决方案 > react-native-swipeout 不适用于android

问题描述

它适用于 ios,但有些不适用于 Android。我正在使用tab navigationFlatList。在里面FlatList我正在使用Swipeout. 下面以代码为例。

const renderItem =()=>{
  return (
    <Swipeout {...swipeAction(index,item, 'REMOVE ITEM',) }>
        <View>
            <Text>Swipe me left</Text>
        </View>
    </Swipeout>
  )
}
const list= <FlatList renderItem={renderItem} />

TabNavigator({
  itemList: { screen: list },
  navigationOptions: {
    header: null,
  }
})

标签: react-nativeswipereact-navigation

解决方案


只需为选项卡导航器添加一个额外的参数。swipeEnabled: false

const renderItem =()=>{
 return (
   <Swipeout {...swipeAction(index,item, 'REMOVE ITEM',) }>
    <View>
        <Text>Swipe me left</Text>
    </View>
   </Swipeout>
 )
}
const list = <FlatList renderItem={renderItem} />
TabNavigator({
  itemList: { screen: list },
  navigationOptions: {
  header: null,
  swipeEnabled: false,        
 }
})

推荐阅读