i get the no compatible call signatures error and dont know what to do to make it work.
React-State
this.state = {
categoryState: ...,
categoryItemId
}
Category declaration
let category: Cat1[] | Cat2[] | Cat3[] = this.getCategory();
getMethod to return category
private getCategory() {
switch (this.state.categoryState) {
case "Cat1": {
return this.props.cat1 as Cat1[];
}
case "EVENT": {
return this.props.cat2 as Cat2[];
}
default: {
return this.props.cat3 as Cat3[];
}
}
}
return-Method (react) this is where the error happens:
<select value={this.state.categoryItemID} onChange={this.handleSomething}>
{(category && category.length > 0) &&
category.map((item: any) => {
return (
<option value={item.id}
key={item.id}>{item.localizations[this.props.currentLanguage].title}</option>
);
})
}
</select>
error message: TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((callbackfn: (value: Cat1, index: number, array: Cat1[]) => U, thisArg?: any) => U[] |...' has no compatible call signatures.
See Question&Answers more detail:os