0
我从@types/immutability-helper
导入update
。现在我想将一个项目推送到一个React组件状态的数组中。在打字稿中使用不变性帮手并作出反应
在index.d.ts
文件的语法说:
interface UpdateFunction {
(value: any[], spec: UpdateArraySpec): any[];
(value: {}, spec: UpdateSpec): any;
extend: (commandName: string, handler: CommandHandler) => any;
}
和UpdateArraySpec
是
interface UpdateArraySpec extends UpdateSpecCommand {
$push?: any[];
$unshift?: any[];
$splice?: any[][];
[customCommand: string]: any;
}
意思我有写2个更新?:
this.setState(update(this.state, update(this.state.Markers, { $push: [info] })));
还是什么?