I just started with the TS .What class should I set for the onGetData in the interface. Because as I know, any cannot be left in the code
interface Props {
onGetData: any;
}
class TSSS extends Component<Props> {
componentDidMount() {
this.props.onGetData();
}
render() {
return <div></div>;
}
}
export default connect((dispatch: any) => ({
onGetData: () => {
dispatch(getUsersData());
},
}))(TSSS);
maybe you can use : Function as the type in interface so the code will be:
interface Props {
onGetData: Function;
}
class TSSS extends Component<Props> {
componentDidMount() {
this.props.onGetData();
}
render() {
return <div></div>;
}
}
export default connect((dispatch: any) => ({
onGetData: () => {
dispatch(getUsersData());
},
}))(TSSS);
or, if you are using visual studio code, you can hover into your function onGetData to see what the type data of the function is, and select that copy and paste into your interface Props of onGetData