相关疑难解决方法(0)

滑动删除不会关闭Swipeable React本机

我正在使用react-native-gesture-handler进行滑动删除目的。它做得很好,但是每当我滑动删除它时,它都会删除该行,但不会关闭Swipeable。我必须向左滑动才能将其关闭。不明白为什么会这样。我在这里提供代码:

import Swipeable from 'react-native-gesture-handler/Swipeable';

    LeftActions = (progress,dragX)=>{
  const scale = dragX.interpolate({
    inputRange: [0, 100],
    outputRange: [0, 1],
    extrapolate: 'clamp',
  });
  return(
    <View style={styles.leftAction}>
      <Animated.Text 
      style={[
          styles.textAction,
          {
            transform:[{
              scale
            }]
          }
        ]}>Delete</Animated.Text>
    </View>
  )
}

class SwipeList extends React.Component {
constructor(props) {
    super(props);
}

SwipeableRow = ({ item, index }) => {
  return (
      <Swipeable
        renderLeftActions={LeftActions}
        renderRightActions={RightActions}
        onSwipeableLeftOpen={()=>this.deleteRow(index)}
      >
        <View style={{paddingHorizontal:10,backgroundColor:'#fff',paddingVertical:20}}>
          <Text style={styles.fromText}>{item.from}</Text>
          <Text numberOfLines={2} style={styles.messageText}>
            {item.message}
          </Text>
        </View>
       </Swipeable>
    );
};
state = {
    list:[
      {
        from: "1", …
Run Code Online (Sandbox Code Playgroud)

react-native

5
推荐指数
2
解决办法
166
查看次数

标签 统计

react-native ×1