【发布时间】:2018-01-03 19:32:41
【问题描述】:
在我的 React-Redux 应用程序中,我正在更改 redux state,它看起来像这样
state {
key1: oldVal1
key2: oldArray1 //The value here is an array
.
.
.
}
现在当我下次更新状态时...
state {
key1: newVal1
//But for key2 I want to keep the value as the same oldArray1
//Now since that oldArray1 is not anywhere except in the old state, can I do this...?
key2: state.key2
.
.
.
}
所以如果我这样做 key2: state.key2 和 state.key2 是一个数组,引用是否会丢失,因为 state 已更改并且 state.key2 不会指向任何东西?
我只想粗略解释一下object/array 引用将如何影响 redux 中的状态。
【问题讨论】:
标签: javascript redux react-redux pass-by-reference