Skip to content

Instantly share code, notes, and snippets.

@philippkeller
Created March 12, 2023 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippkeller/05061029645dd7be9da6fa0e4c9d1b1c to your computer and use it in GitHub Desktop.
Save philippkeller/05061029645dd7be9da6fa0e4c9d1b1c to your computer and use it in GitHub Desktop.
for howto.philippkeller.com blogpost
import React from 'react';
import {useSortable} from '@dnd-kit/sortable';
import {CSS} from '@dnd-kit/utilities';
export function SortableItem(props) {
const {
attributes,
listeners,
setNodeRef,
transform,
transition,
} = useSortable({id: props.id});
const style = {
transform: CSS.Transform.toString(transform),
transition,
};
return (
<div ref={setNodeRef} style={style} {...attributes} {...listeners}>
{props.children}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment