我有这个功能:
setNotActiveWalletsList = () => {
const { GetAccounts } = this.props;
let shallowCopyOfWalletsArray = [...GetAccounts]
const notActive = shallowCopyOfWalletsArray.filter(user => user.active !== true);
let newArr = notActive.map(item => {
return decryptAccountInformation(item).then(result => {
!result.address ? null : item.address = result.address
})
});
this.setState({ onlyNotActive: newArr });
}
GetAccounts 是一个对象数组
问题是,我的一位同事告诉我,我正在用这一行改变数组:
!result.address ? null : item.address = result.address
但我真的不明白为什么这被认为是突变?我确定我创建了原始数组的副本并对其进行了修改。
关于如何解决这个问题的任何建议?