请教一下,在 ionic-react
示例中有如下的一段定义 connect
功能的代码块
/src/data/connect.tsx line:6
interface ConnectParams<TOwnProps, TStateProps, TDispatchProps> {
mapStateToProps?: (state: AppState, props: TOwnProps) => TStateProps,
mapDispatchToProps?: TDispatchProps,
component: React.ComponentType<any>
};
export function connect<TOwnProps = any, TStateProps = any, TDispatchProps = any>({ mapStateToProps = () => ({} as TStateProps), mapDispatchToProps = {} as TDispatchProps, component }: ConnectParams<TOwnProps, TStateProps, TDispatchProps>): React.FunctionComponent<TOwnProps> {
// ...
}
有几个不太懂的地方
interface
定义中接 <TOwnProps, TStateProps, TDispatchProps>
的写法在各文档中都未找到相关资料,请教下是什么意思?export function connect
后的参数类型限制似乎与形参未能对应上,该怎么理解?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…