我试图这样做:
const rowObj = {key: value};
const rowIndex = 2;
this.setState({
data: update(this.state.data,
{ [rowIndex] : { $push : [rowObj] } }
)
})
但是,它会抛出这样的错误:
Uncaught Error: update(): expected target of $push to be an array; got undefined.