Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
rn-gesture-swipeable-flatlist
Advanced tools
SwipeableFlatList is a custom component that combines the functionality of FlatList and Swipeable from React Native and React Native Gesture Handler to create a swipeable list. It allows you to easily render a list of items that can be swiped to reveal additional actions.
This package uses usual, core components from both packages listed above - so this should work with any kind of React Native App and should have a high performance on both platforms.
You can also pass additional props supported by FlatList & Swipeable to customize the behavior and appearance of the list.
Install the package & peer dependencies using npm or yarn:
npm install rn-gesture-swipeable-flatlist
npm install --save react-native-gesture-handler
yarn add rn-gesture-swipeable-flatlist
yarn add react-native-gesture-handler
If you are using expo, make sure you install your expo sdk compatible gesture handler version version by running:
expo install react-native-gesture-handler
Versions v2.0.0+ should wrap the project root (in App.tsx) in GestureHandlerRootView
from react-native-gesture-handler
.
Check react-native-gesture-handler installation docs
import SwipeableFlatList from 'rn-gesture-swipeable-flatlist';
// Example usage
const MyComponent = () => {
const data = [...]; // Your data array
const renderItem = ({ item }) => {
// Render individual list items
return (
// Your list item component JSX
);
};
const renderLeftActions = (item) => {
// Render left swipe actions for each item
return (
// Your left actions component JSX
);
};
const renderRightActions = (item) => {
// Render right swipe actions for each item
return (
// Your right actions component JSX
);
};
return (
<SwipeableFlatList
data={data}
keyExtractor={(item) => item.id}
renderItem={renderItem}
renderLeftActions={renderLeftActions}
renderRightActions={renderRightActions}
/>
);
};
The SwipeableFlatList component accepts the following props:
As the rn-gesture-swipeable-flatlist uses Flatlist from react-native core package, it can be passed FlatlistProps as the usual Flatlist. Check general FlatlistProps here
As the rn-gesture-swipeable-flatlist uses Swipeable component, it can be passed SwipeableProps, so you can adjust your SwipeableItem of the flatlist. Check general SwipeableProps here All the SwipeableProps can be passed under SwipeableProps prop to SwipeableFlatlist:
<SwipeableFlatList
swipeableProps={{
enabled: true
}}
>
A function that returns the component to render as left swipe actions for each item. This is actually a SwipeableProp, but for the simplicity, as you will mostly using left/right actions, it can be passed directly to the SwipeableFlatList.
Similarly to the one above, this is the function that returns the component to render as right swipe actions for each item. This is also a SwipeableProp, but for the simplicity, as you will mostly using left/right actions, it can be passed directly to the SwipeableFlatList.
This is the prop to enable/disable multiple rows being opened. if enabled you can swipe multiple rows and they'll stay open, if disabled - only one row can be opened at a time and the previous one will be closed if you open the new one. Defaults to true
.
(please note, that when you'll alter this prop, you'll need to reinitialize the list - simply refresh the js bundle and the changes will be applied)
The ref is passed to the base Flatlist
component and you can access all the native api available methods through this. Special interface SwipeableFlatListRef
will add a custom module related function to this ref
which is closeAnyOpenRows
- see the description below.
SwipeableFlatList provides a method closeAnyExistingRows()
accessible via a ref to the component. This method can be used to programmatically close any opened rows:
enableOpenMultipleRows
is true: The method closes all swipeable rows that are currently open.enableOpenMultipleRows
is false: The method closes the currently open swipeable row, if any.This method is particularly useful in scenarios where you need to ensure that all swipe actions are reset, such as when navigating away from the list or performing batch actions on the list data.
example usage:
const flatlistRef = useRef<SwipeableFlatListRef<DataItem> | null>(null);
const closeAllOpenRows = () => {
flatListRef.current?.closeAnyOpenRows();
};
return (
<SwipeableFlatList
ref={flatListRef}
data={data}
keyExtractor={(item) => item.id}
renderItem={renderItem}
renderLeftActions={renderLeftAction}
renderRightActions={renderRightAction}
/>
);
Contributions are welcome! If you find any issues or would like to suggest improvements, please create a new issue or submit a pull request.
This project is licensed under the ISC License.
rn-gesture-swipeable-flatlist
has a peer dependency on react-native-gesture-handler
. It will be installed automatically when you install this package. However, please ensure that your project meets the requirements for react-native-gesture-handler
.
FAQs
Swipeable FlatList for React Native
The npm package rn-gesture-swipeable-flatlist receives a total of 89 weekly downloads. As such, rn-gesture-swipeable-flatlist popularity was classified as not popular.
We found that rn-gesture-swipeable-flatlist demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.