As a frontend project, SortableJS/react-sortablejs has picked up 2.2k stars on GitHub (TypeScript). React bindings for SortableJS
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
- Shopping List: # list of items / sortable. This represents `react-sortablejs`
- eggs # list item. These are all the items in the list and are what you move around.
- bread # list item
- milk # list item
These are all default DOM attributes. Nothing special here.
list
The same as state in const [ state, setState] = useState([{ id: 1}, {id: 2}])
state must be an array of items, with each item being an object that has the following shape:
/** The unique id associated with your item. It's recommended this is the same as the key prop for your list item. */
id: string | number;
/** When true, the item is selected using MultiDrag */
selected?: boolean;
/** When true, the item is deemed "chosen", which basically just a mousedown event. */
chosen?: boolean;
/** When true, it will not be possible to pick this item up in the list. */
filtered?: boolean;
[property: string]: any;
setList
The same as setState in const [ state, setState] = useState([{ id: 1}, {id: 2}])
clone
If you're using {group: { name: 'groupName', pull: 'clone'}}, this means you're in 'clone' mode. You should provide a function for this.
Check out the source code of the clone example for more information. I'll write it here soon.
tag
ReactSortable is a div element by default. This can be changed to be any HTML element (for example ul, ol)
or can be a React component.
This value, be it the component or the HTML element, should be passed down under props.tag.
Let's explore both here.
HTML Element
Here we will use an ul. You can use any HTML.
Just add the string and ReactSortable will use a ul instead of a div.
When using a custom component in the tag prop, the only component it allows is a forwardRef component.
Currently, we only support components that use the React.forwardRef API.
If it doesn't have one, you can add one using React.forwardRef().
todo: Some third-party UI components may have nested elements to create the look they're after.
This could be an issue and not sure how to fix it.
import React, { FC, useState, forwardRef } from "react";
import { ReactSortable } from "react-sortablejs";
// This is just like a normal component, but now has a ref.
const CustomComponent = forwardRef<HTMLDivElement, any>((props, ref) => {
return <div ref={ref}>{props.children}</div>;
});
export const BasicFunction: FC = (props) => {
const [state, setState] = useState([
{ id: 1, name: "shrek" },
{ id: 2, name: "fiona" },
]);
return (
<ReactSortable tag={CustomComponent} list={state} setList={setState}>
{state.map((item) => (
<div key={item.id}>{item.name}</div>
))}
</ReactSortable>
);
};
How does it work?
Sortable affects the DOM, adding, and removing nodes/css when it needs to in order to achieve the smooth transitions we all know an love.
This component reverses many of its actions of the DOM so React can handle this when the state changes.
Caveats / Gotchas
key !== index
DO NOT use the index as a key for your list items. Sorting will not work.
In all the examples above, I used an object with an ID. You should do the same!
I may even enforce this into the design to eliminate errors.
Nesting
Problem
Basically, the child updates the state twice. I'm working on this.
What does work?
Our usage indicates that as long as we only move items between lists that don't use the same setState function.
I hope to provide an example soon.
Solutions
We don't have anything that works 100%, but here I'd like to spitball some potential avenues to look down.
Use onMove to handle state changes instead of onAdd,onRemove, etc.
Create a Sortable plugin specifically for react-sortbalejs
How active is development on SortableJS/react-sortablejs?
The most recent commit recorded on SortableJS/react-sortablejs was 2.8 years ago, based on the GitHub push timestamp. The repository has 215 forks — one of the better signals of community interest.
How many stars does SortableJS/react-sortablejs have?
SortableJS/react-sortablejs has 2.2k GitHub stars — refresh the page for the live number, or check github.com/SortableJS/react-sortablejs. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What else is in the Frontend space?
SortableJS/react-sortablejs is tracked by TopGit under the Frontend category, alongside 5 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What language is SortableJS/react-sortablejs written in?
SortableJS/react-sortablejs is written primarily in TypeScript. GitHub's language field is based on the largest share of bytes in the default branch.
What topics is SortableJS/react-sortablejs associated with?
GitHub's repository topics for SortableJS/react-sortablejs: "drag-and-drop", "draggable", "multidrag", "react", "sortable". TopGit's editorial category is Frontend.
Where do I read more about SortableJS/react-sortablejs?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/SortableJS/react-sortablejs is the definitive source.
Why is SortableJS/react-sortablejs categorized under Frontend?
TopGit places SortableJS/react-sortablejs in the Frontend category based on its GitHub topics and description (tagged: "drag-and-drop", "draggable", "multidrag"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Is react-sortablejs worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of react-sortablejs.