在我启动的extreact powered应用程序中,我正在使用Redux进行状态管理,我所在的组件(List)需要来自redux存储的数据。List组件需要一个store参数,我知道如何创建该参数,但我不知道如何将其与redux存储耦合。
我从Sencha博客中找到了一个例子,但它恰恰缺少我感兴趣的部分:
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Grid } from '@extjs/ext-react';
import { connect } from 'react-redux';
export default class EmployeesGrid extends Component {
static propTypes = {
criteria: PropTypes.object
};
store = new Ext.data.Store({
...
});
componentDidUpdate(prevProps) {
const { criteria } = this.props;
if (prevProps.criteria !== criteria) {
const filters = [];
for (let name in criteria) {
filters.push({
property: name,
value: criteria[name]
})
}
this.store.filter(filters)
}
}
render() {
return (
<Grid
store={this.store}
...
/>
)
}
}
const mapStateToProps = (state) => {
return { criteria: state.criteria }
};
export default connect(mapStateToProps)(EmployeesGrid);例如,Ext.data.Store如何获取这些项,以及这些项在componentDidUpdate上是如何更新的?
发布于 2019-10-11 17:56:21
免责声明:我是一名ExtJs开发人员,也是一名React/Redux开发人员,但还没有一起尝试过。
我认为你的例子来自于this article
您发布了选项2的示例,其中他们写入的数据不存储在redux中,而只是ExtJs Grid的过滤条件。数据在ExtJs Store中的React/Redux之外处理,您需要使用their API进行数据(重新)加载。
https://stackoverflow.com/questions/58252785
复制相似问题