- 
                Notifications
    You must be signed in to change notification settings 
- Fork 974
Open
Description
According to the type definition, nodes of onSortEnd is an array of HTMLElement:
react-sortable-hoc/types/index.d.ts
Lines 26 to 32 in caf3c4f
| export interface SortEnd { | |
| oldIndex: number; | |
| newIndex: number; | |
| collection: Offset; | |
| isKeySorting: boolean; | |
| nodes: 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.
Metadata
Metadata
Assignees
Labels
No labels