
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
react-sortable-component
Advanced tools
A simple sortable component for ReactJS.
npm install --save react-sortable-component
var {SortableItems, SortableItem} = require('react-sortable-component');
...
getInitialState: function () {
return {
items: [
{src: 'http://lorempixel.com/400/400/sports/1'},
{src: 'http://lorempixel.com/400/400/sports/2'},
{src: 'http://lorempixel.com/400/400/sports/3'},
{src: 'http://lorempixel.com/400/400/sports/4'},
{src: 'http://lorempixel.com/400/400/sports/5'},
{src: 'http://lorempixel.com/400/400/sports/6'},
{src: 'http://lorempixel.com/400/400/sports/7'}
]
};
},
handleSort: function (items) {
this.setState({
items: items
});
},
render: function () {
var items = this.state.items.map(function (item) {
return (
<SortableItem key={item.src} className='sort-sample-item'>
<LazySizes className='pointer-events-none' dataSrc={item.src}
width='126'
height='126'/>
</SortableItem>
);
});
return (
<div>
<SortableItems name='sort-sample' className='sort-sample-items'
items={this.state.items} onSort={this.handleSort}>
{items}
</SortableItems>
</div>
);
}
Webpack:
require('react-sortable-component/lib/sortable.css');
Without Webpack:
<link rel="stylesheet" type="text/css" href="path/to/react-sortable-component/lib/sortable.css">
or apply your style:
[draggable] {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-user-drag: element;
}
.sortable-items:before,
.sortable-items:after {
content: " ";
display: table;
}
.sortable-items:after {
clear: both;
}
.sortable-item {
height: 150px;
width: 150px;
padding: 10px;
border-radius: 5px;
float: left;
margin-left: 10px;
text-align: center;
border: 2px solid #000;
background-color: #eee;
cursor: move;
}
.sortable-item .point-events-none {
pointer-events: none;
}
.sortable-item-over {
border: 2px dashed #000;
}
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | true | ||
| children | node | true | List of SortableItem | |
| items | array | false | List item need sort. | |
| sort | function | false | See | |
| onSort | function(arg) | false | Callback when items sorted. If items prop is defined then arg is sorted items else arg is list index of sorted items. | |
| className | string | false | Your custom class name. |
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| children | node | true | Sortable item content. | |
| draggable | bool | false | true | |
| className | string | false | Your custom class name. |
View demo or example folder.
FAQs
Sortable component for ReactJS.
The npm package react-sortable-component receives a total of 15 weekly downloads. As such, react-sortable-component popularity was classified as not popular.
We found that react-sortable-component demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.