react-native-swipe-list-view
A React Native ListView component with rows that swipe open and closed
Top Related Projects
react-native-app-intro is a react native component implementing a parallax effect welcome page using base on react-native-swiper , similar to the one found in Google's app like Sheet, Drive, Docs...
Awesome React Native components, news, tools, and learning material!
A complete native navigation solution for React Native
A Camera component for React Native. Also supports barcode scanning!
Customizable Icons for React Native with support for image source and full styling.
React Native Mapview component for iOS + Android
Quick Overview
React Native Swipe List View is a versatile component for React Native that provides swipeable row functionality. It allows developers to create lists with hidden content or actions that can be revealed by swiping left or right on a row, enhancing the user interface and interaction in mobile applications.
Pros
- Easy integration with existing React Native projects
- Highly customizable with various props and styling options
- Supports both iOS and Android platforms
- Includes built-in animations for smooth user experience
Cons
- May require additional performance optimization for large lists
- Limited documentation for advanced use cases
- Some users report occasional issues with touch sensitivity
- Might have a slight learning curve for developers new to swipeable components
Code Examples
- Basic usage of SwipeListView:
import { SwipeListView } from 'react-native-swipe-list-view';
const MyComponent = () => (
<SwipeListView
data={listData}
renderItem={ (data, rowMap) => (
<View>
<Text>{data.item.title}</Text>
</View>
)}
renderHiddenItem={ (data, rowMap) => (
<View style={styles.rowBack}>
<Text>Delete</Text>
</View>
)}
leftOpenValue={75}
rightOpenValue={-75}
/>
);
- Adding swipe actions:
<SwipeListView
data={listData}
renderItem={renderItem}
renderHiddenItem={renderHiddenItem}
leftOpenValue={75}
rightOpenValue={-75}
onRowOpen={(rowKey, rowMap) => {
console.log('This row opened', rowKey);
}}
onSwipeValueChange={(swipeData) => {
const { key, value } = swipeData;
if (value < -50) {
console.log('Swiped left more than 50%');
}
}}
/>
- Customizing swipe thresholds:
<SwipeListView
data={listData}
renderItem={renderItem}
renderHiddenItem={renderHiddenItem}
leftOpenValue={75}
rightOpenValue={-75}
swipeToOpenPercent={40}
swipeToClosePercent={30}
disableLeftSwipe={false}
disableRightSwipe={false}
/>
Getting Started
-
Install the package:
npm install react-native-swipe-list-view
-
Import the component:
import { SwipeListView } from 'react-native-swipe-list-view';
-
Use the component in your React Native app:
const MyComponent = () => ( <SwipeListView data={listData} renderItem={(data, rowMap) => ( <View> <Text>{data.item.title}</Text> </View> )} renderHiddenItem={(data, rowMap) => ( <View style={styles.rowBack}> <Text>Delete</Text> </View> )} leftOpenValue={75} rightOpenValue={-75} /> );
-
Customize the component using props and styles as needed for your specific use case.
Competitor Comparisons
react-native-app-intro is a react native component implementing a parallax effect welcome page using base on react-native-swiper , similar to the one found in Google's app like Sheet, Drive, Docs...
Pros of react-native-app-intro
- Specifically designed for creating app introduction/onboarding screens
- Provides a set of pre-built components for quick implementation
- Offers customizable pagination and skip/done buttons
Cons of react-native-app-intro
- Less actively maintained (last update was 6 years ago)
- Limited functionality beyond app introductions
- Fewer stars and contributors compared to react-native-swipe-list-view
Code Comparison
react-native-app-intro:
<AppIntro>
<View style={[styles.slide,{ backgroundColor: '#fa931d' }]}>
<View level={10}><Text style={styles.text}>Page 1</Text></View>
<View level={15}><Text style={styles.text}>Page 1</Text></View>
<View level={8}><Text style={styles.text}>Page 1</Text></View>
</View>
// ... more slides
</AppIntro>
react-native-swipe-list-view:
<SwipeListView
data={listData}
renderItem={ (data, rowMap) => (
<View style={styles.rowFront}>
<Text>I am {data.item.text} in a SwipeListView</Text>
</View>
)}
renderHiddenItem={ (data, rowMap) => (
<View style={styles.rowBack}>
<Text>Delete</Text>
</View>
)}
leftOpenValue={75}
rightOpenValue={-75}
/>
The code snippets highlight the different purposes of these libraries. react-native-app-intro focuses on creating introduction screens with customizable views, while react-native-swipe-list-view provides a swipeable list component with hidden actions.
Awesome React Native components, news, tools, and learning material!
Pros of awesome-react-native
- Comprehensive resource collection for React Native development
- Regularly updated with new tools, libraries, and resources
- Covers a wide range of topics, from UI components to testing frameworks
Cons of awesome-react-native
- Not a specific component or library, but a curated list
- Requires additional effort to evaluate and integrate individual resources
- May include outdated or deprecated items if not frequently maintained
Code comparison
As awesome-react-native is a curated list and not a specific component, a direct code comparison is not applicable. However, here's an example of how you might use a component listed in awesome-react-native versus react-native-swipe-list-view:
react-native-swipe-list-view:
import { SwipeListView } from 'react-native-swipe-list-view';
<SwipeListView
data={listData}
renderItem={renderItem}
renderHiddenItem={renderHiddenItem}
leftOpenValue={75}
rightOpenValue={-75}
/>
Component from awesome-react-native (e.g., react-native-elements):
import { ListItem } from 'react-native-elements';
<ListItem
title="List Item"
subtitle="Subtitle"
leftAvatar={{ source: { uri: 'avatar_url' } }}
bottomDivider
chevron
/>
While react-native-swipe-list-view provides specific swipe functionality, awesome-react-native offers a variety of components and resources to choose from based on your project needs.
A complete native navigation solution for React Native
Pros of react-native-navigation
- Offers a more comprehensive navigation solution with support for complex navigation patterns
- Provides native navigation performance and animations
- Includes built-in support for deep linking and tab-based navigation
Cons of react-native-navigation
- Steeper learning curve due to its more complex API
- Requires additional setup and configuration compared to simpler navigation libraries
- May introduce compatibility issues with certain React Native versions or other libraries
Code Comparison
react-native-navigation:
Navigation.setRoot({
root: {
stack: {
children: [
{
component: {
name: 'Home'
}
}
]
}
}
});
react-native-swipe-list-view:
<SwipeListView
data={listData}
renderItem={renderItem}
renderHiddenItem={renderHiddenItem}
leftOpenValue={75}
rightOpenValue={-75}
/>
While react-native-navigation focuses on overall app navigation, react-native-swipe-list-view is specifically designed for creating swipeable list views. The code comparison shows the different purposes and usage of these libraries. react-native-navigation requires setting up a navigation structure, while react-native-swipe-list-view is used within a component to create an interactive list.
A Camera component for React Native. Also supports barcode scanning!
Pros of react-native-camera
- Comprehensive camera functionality, including photo capture, video recording, and barcode scanning
- Extensive platform-specific features for both iOS and Android
- Active community and frequent updates
Cons of react-native-camera
- More complex setup and configuration compared to react-native-swipe-list-view
- Larger package size due to its extensive feature set
- May require additional permissions and setup for certain features
Code Comparison
react-native-camera:
import { RNCamera } from 'react-native-camera';
<RNCamera
style={styles.preview}
type={RNCamera.Constants.Type.back}
flashMode={RNCamera.Constants.FlashMode.on}
androidCameraPermissionOptions={{
title: 'Permission to use camera',
message: 'We need your permission to use your camera',
buttonPositive: 'Ok',
buttonNegative: 'Cancel',
}}
/>
react-native-swipe-list-view:
import { SwipeListView } from 'react-native-swipe-list-view';
<SwipeListView
data={listData}
renderItem={ (data, rowMap) => (
<View style={styles.rowFront}>
<Text>I am {data.item.text} in a SwipeListView</Text>
</View>
)}
renderHiddenItem={ (data, rowMap) => (
<View style={styles.rowBack}>
<Text>Delete</Text>
</View>
)}
leftOpenValue={75}
rightOpenValue={-75}
/>
Customizable Icons for React Native with support for image source and full styling.
Pros of react-native-vector-icons
- Extensive icon library with multiple icon sets
- Easy customization of icon size, color, and style
- Supports both iOS and Android platforms
Cons of react-native-vector-icons
- Not focused on list view functionality
- Requires additional setup for custom icons
- May increase app bundle size due to icon assets
Code Comparison
react-native-vector-icons:
import Icon from 'react-native-vector-icons/FontAwesome';
<Icon name="rocket" size={30} color="#900" />
react-native-swipe-list-view:
import { SwipeListView } from 'react-native-swipe-list-view';
<SwipeListView
data={listData}
renderItem={renderItem}
renderHiddenItem={renderHiddenItem}
leftOpenValue={75}
rightOpenValue={-75}
/>
react-native-vector-icons focuses on providing a wide range of customizable icons for React Native applications, while react-native-swipe-list-view specializes in creating swipeable list views with hidden actions. The former is ideal for adding visual elements and iconography to your app, while the latter is better suited for implementing interactive list interfaces with swipe gestures.
react-native-vector-icons offers a simpler API for rendering individual icons, whereas react-native-swipe-list-view provides a more complex component for handling swipeable list items with custom rendering functions.
Choose react-native-vector-icons for icon-related needs and react-native-swipe-list-view for implementing swipeable list functionality in your React Native project.
React Native Mapview component for iOS + Android
Pros of react-native-maps
- Provides comprehensive mapping functionality for React Native apps
- Supports both iOS and Android platforms with native map implementations
- Offers a wide range of customization options and map features
Cons of react-native-maps
- More complex setup and configuration compared to react-native-swipe-list-view
- Larger package size and potential performance impact due to map rendering
- May require additional permissions and API keys for full functionality
Code Comparison
react-native-maps:
import MapView, { Marker } from 'react-native-maps';
<MapView
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
>
<Marker coordinate={{ latitude: 37.78825, longitude: -122.4324 }} />
</MapView>
react-native-swipe-list-view:
import { SwipeListView } from 'react-native-swipe-list-view';
<SwipeListView
data={listData}
renderItem={ (data, rowMap) => (
<View>
<Text>{data.item.title}</Text>
</View>
)}
renderHiddenItem={ (data, rowMap) => (
<View style={styles.rowBack}>
<Text>Delete</Text>
</View>
)}
rightOpenValue={-75}
/>
The code examples showcase the primary use cases for each library. react-native-maps focuses on rendering maps and markers, while react-native-swipe-list-view provides swipeable list functionality.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
react-native-swipe-list-view
<SwipeListView>
is a vertical ListView with rows that swipe open and closed. Handles default native behavior such as closing rows when ListView is scrolled or when other rows are opened.
Also includes <SwipeRow>
if you want to use a swipeable row outside of the <SwipeListView>
ð¥ð¥ BREAKING CHANGES ð¥ð¥
For use with RN 0.60+ please use react-native-swipe-list-view@2.0.0+
RN 0.60 and RNSLV 2.0.0 deprecate the use of ListView entirely, please see example.js
for examples and see the migrating-to-flatlist doc for a migration guide if you aren't already using FlatList
.
The useFlatList
prop is no longer required, as FlatList
is the default ListView used.
Example
Try it out! https://snack.expo.io/@jemise111/react-native-swipe-list-view
Installation
npm install --save react-native-swipe-list-view
Running the example
The application under ./SwipeListExample will produce the above example. To run execute the following:
git clone https://github.com/jemise111/react-native-swipe-list-view.git
cd react-native-swipe-list-view
cd SwipeListExample
yarn
cd ios
pod install
cd ..
react-native run-ios | react-native run-android
Android: If you get the following error
SwipeListExample/android/app/debug.keystore' not found for signing config 'debug'.
:cd android/app/ && keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 // answer the questions cd ../..
Usage
import { SwipeListView } from 'react-native-swipe-list-view';
//... note: your data array objects MUST contain a key property
// or you must pass a keyExtractor to the SwipeListView to ensure proper functionality
// see: https://reactnative.dev/docs/flatlist#keyextractor
this.state.listViewData = Array(20)
.fill("")
.map((_, i) => ({ key: `${i}`, text: `item #${i}` }));
//...
render() {
return (
<SwipeListView
data={this.state.listViewData}
renderItem={ (data, rowMap) => (
<View style={styles.rowFront}>
<Text>I am {data.item.text} in a SwipeListView</Text>
</View>
)}
renderHiddenItem={ (data, rowMap) => (
<View style={styles.rowBack}>
<Text>Left</Text>
<Text>Right</Text>
</View>
)}
leftOpenValue={75}
rightOpenValue={-75}
/>
)
}
See example.js
for full usage guide (including using <SwipeRow>
by itself)
Note:
If your row is touchable (TouchableOpacity, TouchableHighlight, etc.) with an onPress
function make sure renderItem
returns the Touchable as the topmost element.
GOOD:
renderItem={ data => (
<TouchableHighlight onPress={this.doSomething.bind(this)}>
<View>
<Text>I am {data.item} in a SwipeListView</Text>
</View>
</TouchableHighlight>
)}
BAD:
renderItem={ data => (
<View>
<TouchableHighlight onPress={this.doSomething.bind(this)}>
<Text>I am {data.item} in a SwipeListView</Text>
</TouchableHighlight>
</View>
)}
Component APIs
Flatlist / SectionList support
SwipeListView
now supports FlatList
and SectionList
! (as of v1.0.0)
Please see the migrating-to-flatlist doc for all details.
And see example.js
for a full usage example.
Also see docs/
for help with
And the examples/
folder for examples on
- Swipe to Delete (also see "Actions" for an alternative way to achieve this)
- Per Row Behavior
- UI Based on Swipe Values
- Actions
Core Support
RN Core added a SwipeList component as of v0.27.0 It is actively being worked on and has no documentation yet. So I will continue to maintain this component until a future date.
License
MIT
Top Related Projects
react-native-app-intro is a react native component implementing a parallax effect welcome page using base on react-native-swiper , similar to the one found in Google's app like Sheet, Drive, Docs...
Awesome React Native components, news, tools, and learning material!
A complete native navigation solution for React Native
A Camera component for React Native. Also supports barcode scanning!
Customizable Icons for React Native with support for image source and full styling.
React Native Mapview component for iOS + Android
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot