Closed alxvallejo closed 3 years ago
This is an error I see coming up with trying to reorder table rows. Pretty standard implementation:
<List values={questions} onChange={({ oldIndex, newIndex }) => { const newList = arrayMove(questions, oldIndex, newIndex); const newOrder = newList.map((q, i) => { return {id: q.id, order: i} }); setQuestions(newList) orderQuestions(newOrder) }} renderList={({ children, props }) => <Table size="sm" responsive striped ><tbody {...props}>{children}</tbody></Table>} renderItem={({ value, props }) => { const p = value; const field_type = p.field_type.charAt(0).toUpperCase() + p.field_type.slice(1) return ( <tr {...props}> <td>{p.title}</td> <td>{field_type}</td> </tr> ) }} />
Check the table example. The trick is to wrap renderItem with a table element when isDragged is true.
renderItem
isDragged
true
This is an error I see coming up with trying to reorder table rows. Pretty standard implementation: