我有一个对象数组就是这种格式
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
}
]
我正在使用 react-beautiful-dnd 拖放这个对象数组。我希望能够基于拖放以及 isBox 标志来分配索引。这样做最有效的方法是什么。我很困惑,因为该州没有索引。我是否需要向元素添加索引属性才能做到这一点?
https://codesandbox.io/s/react-beautiful-dnd-tutorial-forked-ij1oq?file=/src/index.js