react-sortable-hoc
react-sortable-hoc copied to clipboard
Make it easier to use
You can use the lib much easier if you would include this:
import {SortableContainer, SortableElement, SortableHandle} from "react-sortable-hoc";
const component = ({children}: {children: JSX.Element}) => children;
export const SortableItem = SortableElement(component);
export const SortableList = SortableContainer(component);
export const SortHandle = SortableHandle(component);
Usage:
<SortableList>
<ul>
{this.state.elementForList.map((c, i) =>
<SortableItem key={i} index={i}>
<li>{c}</li>
</SortableItem>
</ul>
)}
</SortableList>
Thanks for this. I created a sortableUtils.ts
which exports these consts, and this does make it sooooo much more pleasant to use.