Cha*_*man 5 javascript reactjs flowtype react-redux
这就是我的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,
},
};
};
Run Code Online (Sandbox Code Playgroud)
这是形状StateProps
type StateProps = {
showModal: boolean,
currentProduct: Object,
isLoading: boolean,
initialValues: {
name: string,
status: boolean,
}
}
Run Code Online (Sandbox Code Playgroud)
这是我对连接的用法。
const connected = connect<React$StatelessFunctionalComponent<any>, StateProps>(mapStateToProps, mapDispatchToProps);
Run Code Online (Sandbox Code Playgroud)
这会产生以下错误,我不知道这意味着什么或如何解决它。
[flow] 无法调用,因为类型为 argument 的索引器属性的键 [1] 中缺少
connect
属性。(参考文献:[1])currentProduct
React.StatelessFunctionalComponent
ST
归档时间: |
|
查看次数: |
2755 次 |
最近记录: |