Many people contribute to immutability because they generally use reduction, but I still see that people use push instead of concat.
Take this code, for example:
submitComment() {
console.log('submitComment: '+JSON.stringify(this.state.comment))
APIManager.post('/api/comment', this.state.comment, (err, response) => {
if (err){
alert(err)
return
}
console.log(JSON.stringify(response))
let updateList = Object.assign([], this.state.list)
updatedList.push(response.result)
this.setState({
list: updatedList
})
})
}
In this case, does it matter at all? What is the problem with clicking above?
source
share