配列内のキーの値を不変型ヘルパーアドオンで更新したいとします。配列インデックス値をオブジェクトとして更新する
私のコードは次のようになります。
class StorageForm extends Component {
constructor(props) {
super(props);
this.state = {
volumes: [{local: 'test', remote: 'test2'}],
};
};
_handleLocalPathData(event, index) {
const path = event.target.value;
const data = this.state.volumes[index];
data.local = path;
const tmpData = update(this.state.volumes[index], {$set: [data]});
this.setState({
volumes: tmpData
});
};
}
が、ボリュームが更新さ1ではありません。私のミスはどこですか?
、私は[すでにが、これを試してみましたindex]私はthis.state.volumes [index]を使用しました。私は後でそれを試してみる。 – Evolutio