Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-virtual-drag-list
Advanced tools
A virtual scrolling list component that can be sorted by dragging
npm i react-virtual-drag-list -D
or
yarn add react-virtual-drag-list -D
Root component:
import virtualList from 'react-virtual-drag-list'
function Virtual() {
const list = [{id: '1', text: 'asd'}, {id: '2', text: 'fgh'}, ...]
const handleToTop = () => {
console.log('istop')
}
const handleToBottom = () => {
console.log('isbottom')
}
const handleDragEnd = (arr) => {
console.log(arr, 'new arr after drag end')
}
return (
<virtualList
dataKey="id"
dataSource={ list }
header={ <div className="loading">top loading...</div> }
footer={ <div className="loading">bottom loading...</div> }
v-top={ handleToTop }
v-bottom={ handleToBottom }
v-dragend={ handleDragEnd }
>
{
(record, index, uniqueKey) => {
return (
<div>
<span draggable>{ index }</span>
{ record.text }
</div>
)
}
}
</virtualList>
)
}
Prop | Type | Required? | Description | Default |
---|---|---|---|---|
dataKey | String | ✓ | the unique identifier of each piece of data, in the form of 'a.b.c' | - |
dataSource | Array | ✓ | data list | [] |
size | Number | ✓ | estimated height of each row | 50 |
keeps | Number | the number of lines rendered by the virtual scroll | 30 | |
delay | Number | Delay time of debounce function | 10 | |
draggable | Boolean | whether to support drag and drop. You need to specify a draggable element and set the draggable attribute for it | true | |
dragElement | Function | The function that selects the dragged element, must have a return value with a dom node, has two parameters: e(the currently selected element), parent(the parent node of the list) | - | |
header | JSX.Element | top of list | - | |
footer | JSX.Element | bottom of list | - | |
v-top | Function | callback function that fires when scrolling to the top | - | |
v-bottom | Function | callback function that fires when scrolling to the bottom | - | |
v-dragend | Function | event when drag is complete | - | |
dragStyle | Object | mask style while dragging | - | |
itemStyle | Object | style for each line | - | |
itemClass | String | class for each line | - |
Use the methods exposed in the component by setting ref
, like this:
...
const virtualRef = useRef()
const scrollToBottom = () => {
virtualRef.current.scrollToBottom()
}
return (
<button onClick={ scrollToBottom }></button>
<virtualList
ref={ virtualRef }
...
>
{
(record) => <div>{ record.text }</div>
}
</virtualList>
)
Prop | Description |
---|---|
reset() | reset to initial |
getSize(key) | get the height of the specified item by key value |
getScrollTop() | get the current scroll height |
scrollToBottom() | scroll to the bottom of the list |
scrollToTop() | scroll to the top of the list |
scrollToOffset(offset) | scroll to the specified height |
scrollToIndex(index) | scroll to the specified index value |
FAQs
A virtual scrolling list component that can be sorted by dragging
The npm package react-virtual-drag-list receives a total of 6,180 weekly downloads. As such, react-virtual-drag-list popularity was classified as popular.
We found that react-virtual-drag-list demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.