一个 React Native ListView 组件,其行可以滑动打开和关闭
<SwipeListView> 是一个垂直的 FlatList(或 SectionList),其行可以滑动打开和关闭。它处理了预期的原生行为:当列表滚动或另一行被打开时,关闭当前行。
它还导出了 <SwipeRow>,用于单独使用可滑动的行。
完整文档: https://jessesessler.com/react-native-swipe-list-view/>
v4 是对 TypeScript、React-native-gesture-handler v2 和
React-native-reanimated v3 的全面重写——手势和动画现在在 UI 线程上运行。
组件 API 与 v3 在 props 上完全兼容,除了一小部分破坏性变更(新增 peer 依赖、移除无用的 ListView props、更改了
swipeGestureEnded 的 payload 等)。
从 v3 升级? 请阅读 迁移指南。
npm install react-native-swipe-list-view
npm install react-native-gesture-handler react-native-reanimatedReact-native-gesture-handler 和 React-native-reanimated 是 peer
依赖(≥2.14.0 和 ≥3.6.0)。安装它们后:
babel.config.js: module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: ['react-native-reanimated/plugin'],
};GestureHandlerRootView 中: import { GestureHandlerRootView } from 'react-native-gesture-handler';
export default function App() {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
{/* ... */}
</GestureHandlerRootView>
);
}请参阅官方设置指南,了解 和 reanimated。
要求: React ≥18,React-native ≥0.73。
[](https://www.npmjs.com/package/react-native-swipe-list-view) [](https://github.com/jemise111/react-native-swipe-list-view/actions/workflows/ci.yml)
[gesture-handler](https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation)暂无开放 Issues,或尚未同步最近议题。