2017-04-14 6 views

답변

4
var tempArray = this.props.currentView.someArray; 

은 tempArray가 배열을 참조하게합니다.

tempArray.push()은 참조를 수정합니다.

그래, this.props.currentView.someArray을 수정합니다.

상태를 수정하고 싶지 않으면 할 수 있습니다.

var tempArray = this.props.currentView.someArray.slice(); 

슬라이스는 원래 배열을 수정하고 인수로를 호출하면 원래 배열의 복사본을 반환하지 않습니다. this.props.currentView.someArray

+0

놀라운에는 영향을주지 않습니다이 후 tempArray 수정

, 감사합니다! –