Incorrect type definition provided for nodes argument in onSortEnd prop
Author: smtchahalCreated Jan 7, 2025Updated Jan 7, 2025
According to the type definition, nodes of onSortEnd is an array of HTMLElement:
But in reality, to access the HTMLElement, you need to use nodes[0].node, which triggers TypeScript error:
<MySortableList
// ...
onSortEnd={({ oldIndex, newIndex, nodes }) => {
console.log('nodes are', nodes); // {boundingClientRect: null, edgeOffset: null, node: HTMLElement, translate: null}[]
const node = nodes[0].node
console.log('the actual HTML element is', node);
}}
// ...
/>So it looks like either the typedef is wrong, or the code is wrong.
Source: clauderic/react-sortable-hoc