
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
nested-react-sortablejs
Advanced tools
A React component for creating nested sortable lists using SortableJS
A customizable React component for creating nested sortable lists using SortableJS.
npm install nested-react-sortablejs
# or
yarn add nested-react-sortablejs
import React, { useState } from 'react';
import { NestedSortable } from 'nested-react-sortablejs';
import 'nested-react-sortablejs/dist/style.css'; // Optional default styling
const App = () => {
const [items, setItems] = useState([
{
id: '1',
content: 'Item 1',
children: [
{ id: '1-1', content: 'Item 1.1', children: [] },
{ id: '1-2', content: 'Item 1.2', children: [] }
]
},
{
id: '2',
content: 'Item 2',
children: []
}
]);
const handleDrop = (newItems) => {
setItems(newItems);
console.log('Items updated:', newItems);
};
return (
<NestedSortable
items={items}
onDrop={handleDrop}
/>
);
};
export default App;
You can customize how items are rendered:
import React, { useState } from 'react';
import { NestedSortable } from 'nested-react-sortablejs';
const App = () => {
const [items, setItems] = useState([/* your items */]);
const renderItem = (item, index) => (
<div className="custom-item">
<span className="handle">⋮</span>
<div className="content">{item.content}</div>
{!item.children?.length && (
<button onClick={() => console.log(`Clicked item ${item.id}`)}>
Action
</button>
)}
</div>
);
return (
<NestedSortable
items={items}
onDrop={setItems}
renderItem={renderItem}
/>
);
};
NestedSortable Props| Prop | Type | Default | Description |
|---|---|---|---|
items | NestedItem[] | [] | Array of items to be sorted |
group | string | 'nested' | Group name for Sortable instance |
className | string | '' | Custom class name for the container |
onDrop | (items: NestedItem[]) => void | undefined | Function called when an item is dropped |
options | SortableOptions | {} | Additional Sortable.js options |
renderItem | (item: NestedItem, index: number) => React.ReactNode | undefined | Custom renderer for list items |
NestedItem Interfaceinterface NestedItem {
id: string;
content: string | React.ReactNode;
children?: NestedItem[];
data?: Record<string, any>;
}
You can pass any Sortable.js options via the options prop:
<NestedSortable
items={items}
onDrop={handleDrop}
options={{
animation: 150,
fallbackOnBody: true,
swapThreshold: 0.65,
ghostClass: 'ghost',
chosenClass: 'chosen',
dragClass: 'drag'
}}
/>
The component comes with basic styling that you can import:
import 'nested-react-sortablejs/dist/style.css';
Or you can create your own styles by targeting these CSS classes:
.nested-sortable - The main container.nested-item - Individual sortable items.nested-item-content - Content area of each item.nested-children - Container for nested childrenMIT
FAQs
A React component for creating nested sortable lists using SortableJS
We found that nested-react-sortablejs 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.