【问题标题】:Extreact List with redux state and local store提取具有 redux 状态和本地存储的列表
【发布时间】:2019-10-11 17:56:21
【问题描述】:

我正在使用 Redux 进行状态管理,在我启动的这个 exreact 驱动的应用程序中,我在一个需要来自 redux 存储的数据的组件 (List) 中。 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 上更新?

【问题讨论】:

    标签: extjs redux extreact


    【解决方案1】:

    免责声明:我是一名 ExtJs 开发人员,也是一名 React/Redux 开发人员,但还没有一起尝试过。

    我认为你的例子来自this article

    您发布了选项 2 示例,他们在其中写入数据不存储在 redux 中,仅存储 ExtJs 网格的过滤条件。数据由 ExtJs Store 中的 React/Redux 处理,您需要使用 their API 进行数据(重新)加载。

    【讨论】:

      猜你喜欢
      • 2020-07-22
      • 2022-10-20
      • 1970-01-01
      • 1970-01-01
      • 2019-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多