I imported update from @types/immutability-helper. Now I want to push an item to the an array in a React's component state.
The syntax in index.d.ts file says:
interface UpdateFunction {
(value: any[], spec: UpdateArraySpec): any[];
(value: {}, spec: UpdateSpec): any;
extend: (commandName: string, handler: CommandHandler) => any;
}
and UpdateArraySpec is
interface UpdateArraySpec extends UpdateSpecCommand {
$push?: any[];
$unshift?: any[];
$splice?: any[][];
[customCommand: string]: any;
}
does it mean I have to write 2 updates?:
this.setState(update(this.state, update(this.state.Markers, { $push: [info] })));
Or what?