Created
March 12, 2023 17:17
-
-
Save philippkeller/05061029645dd7be9da6fa0e4c9d1b1c to your computer and use it in GitHub Desktop.
for howto.philippkeller.com blogpost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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