【发布时间】:2019-04-23 03:16:28
【问题描述】:
这就是我的mapStateToProps 的样子。
const mapStateToProps = (state): StateProps => {
let status = false;
if (state.productsPage.currentProduct) {
if (state.productsPage.currentProduct.status === "ACTIVE") {
status = true;
}
}
return {
showModal: state.productsPage.showModal,
currentProduct: state.productsPage.currentProduct,
isLoading: state.status.loading.PRODUCTS_EDIT,
initialValues: {
name: state.productsPage.currentProduct ? state.productsPage.currentProduct.name : "",
status,
},
};
};
这是StateProps的形状
type StateProps = {
showModal: boolean,
currentProduct: Object,
isLoading: boolean,
initialValues: {
name: string,
status: boolean,
}
}
这是我对连接的使用。
const connected = connect<React$StatelessFunctionalComponent<any>, StateProps>(mapStateToProps, mapDispatchToProps);
这会产生以下错误,我不知道这意味着什么或如何解决它。
[流程] 无法调用
connect,因为属性currentProduct是 索引器中的React.StatelessFunctionalComponent[1] 中缺少 类型参数ST的属性键。 (参考文献:[1])
【问题讨论】:
标签: javascript reactjs react-redux flowtype