I have an object array That is in this format
sampleItemDetail: [
{
type: 'Take out the garbage',
isBox1: true
},
{
type: 'Watch my favorite show',
isBox1: true
},
{
type: 'Charge my phone',
isBox2: true
},
{
type: 'Cook dinner',
isBox1: true
},
{
type: 'Take out the garbage1',
isBox2: true
},
{
type: 'Watch my favorite show2',
isBox1: true
},
{
type: 'Charge my phone3',
isBox1: true
}
]
I am using react-beautiful-dnd to drag and drop this array of objects. I want to be able to assign the index based on drag and drop as well as the isBox flag too. What will be the most efficient way of doing this. I am confused since the state does not have index. Would I need to add an index property to the elements to make that happen?
https://codesandbox.io/s/react-beautiful-dnd-tutorial-forked-ij1oq?file=/src/index.js