react-sortable-hoc icon indicating copy to clipboard operation
react-sortable-hoc copied to clipboard

Make it easier to use

Open Felix-Franz opened this issue 4 years ago • 1 comments

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>

Felix-Franz avatar Dec 01 '20 12:12 Felix-Franz

Thanks for this. I created a sortableUtils.ts which exports these consts, and this does make it sooooo much more pleasant to use.

thepuzzlemaster avatar Dec 29 '20 17:12 thepuzzlemaster