2016-04-24 1 views
0

Immutableを使用してこの配列の並べ替えの例を表現する方法は?反応-DNDのため、このコードサンプルから

https://github.com/gaearon/react-dnd/blob/master/examples/04%20Sortable/Simple/Container.js#L46-L53

this.setState(update(this.state, { 
    cards: { 
    $splice: [ 
     [dragIndex, 1], 
     [hoverIndex, 0, dragCard] 
    ] 
    } 
})); 

私は不変を使用して、この同じアクションを実行しようとしているが、どのように把握することはできません。

答えて

0

ありがとうございました!

const cards = state.get('cards'); 
const newState = state.set('cards', 
    cards.splice(dragIndex, 1) 
    .splice(hoverIndex, 0, dragCard)); 
関連する問題