I am having a TypeScript error when calling setState
:
That's what I am actually doing:
updateRequests(requests: any, cb:Function|null = null) { this.setState( { requests: { ...this.state.requests, items: requests, loading: false, }, }, () => { if (cb) cb(); } );
Here's a Component state:
export interface IServersScreenState { requests: { items: []; loading: boolean; statuses: {}; page: number; lastPage: number; scrollLoading: boolean; };}
Don't actually understand why it's happening like that, because I don't have any declaration in the state, that requests
needs to be look like ()=>void
here's my setState:
setState<T>(...args: T[]) { if (this.__mounted__) { //@ts-expect-error spread error super.setState(...args) as $TSFixMe; } }